I need some help folks. I am trying to extract the first name space last name from an email address containing first name dot last name. I was able to complete a work around to extract first name. Then I am to extract the last name but not "subtract" the "@Domain.com from last name portion of the string. I know there is a way to perform this operation with one function.
John.Smith@Domain.com
I need to combine these two porcesses into one process. -
Dim varName as Variant
-
Dim varNameClr as Variant
-
-
varNameClr = Left(rs.Email_ADDR, InStr(rs.Email_ADDR, ".") - 1) & " " & Mid(rs.Email_ADDR, InStr(rs.Email_ADDR, ".") + 1)
-
'returns John Smith@Domain.com
-
-
varName = Left(varNameclr, InStr(varNameclr, "@") - 1)
-
'removes the @domain.com
-
'Returns John Smith
-
-
One could just use Split() and Replace() . - Public Function ParseName(strEmail As String) As String
-
ParseName = Replace(Split(strEmail, "@")(0), ".", " ")
-
End Sub
6 1163
MitchR,
This is probably more than I typically offer, but here is a quick and easy solution: - Option Compare Database
-
Option Explicit
-
-
Public Function NamesFromEmail(EmailAddress As String) As String
-
On Error GoTo EH
-
Dim strEmail As String
-
Dim intAtSign As Integer
-
Dim strFirstLast As String
-
-
strEmail = EmailAddress
-
intAtSign = InStr(strEmail, "@")
-
strEmail = Left(strEmail, intAtSign - 1)
-
strFirstLast = Replace(strEmail, ".", " ")
-
NamesFromEmail = strFirstLast
-
-
Exit Function
-
EH:
-
MsgBox "There was an error splitting the E-Mail address!" & vbCrLf & vbCrLf & _
-
"Error: " & Err.Number & vbCrLf & _
-
"Description: " & Err.Description & vbCrLf & vbCrLf & _
-
"Please contact your Database Administrator.", vbCritical, "WARNING!"
-
Exit Function
-
End Function
Hope this hepps!
NeoPa 32,556
Expert Mod 16PB
One could just use Split() and Replace() . - Public Function ParseName(strEmail As String) As String
-
ParseName = Replace(Split(strEmail, "@")(0), ".", " ")
-
End Sub
@NeoPa
Very, very elegant
Phil
How does he do that? Oh, to get inside the brain of NeoPa!
Thank you @twinnyfo and @NeoPa! NeoPa's solution worked like a surgeon's scalpel with a perfect extraction!
NeoPa 32,556
Expert Mod 16PB
You're very kind. I should just point out though, that while brief, it doesn't include error handling, which Twinny's did of course.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Prasad Karunakaran |
last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of
an user object in the Active Directory. I need to get the First Name
and Last Name as properties. I know it is not supported...
|
by: Edmund Wong |
last post by:
I have one client fiield that stores First and last name. I would like
to separate the names into a lastname field and firstname field. Can
anyone tell me how to do this?
thanks
|
by: Prasad Karunakaran |
last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of
an user object in the Active Directory. I need to get the First Name
and Last Name as properties. I know it is not supported...
|
by: Peter |
last post by:
Using CDO 1.21 how do I get First Name and Last Name from Global Address
Book?
I have the following code where I retrieve LastName and FirstName in one
field, but how do I get LastName and...
|
by: John |
last post by:
Good Day all
I have a single field that has both the first and last names in it.
In some records we even have a middle initial.
I was thinking of using the Left (Fullname,XX) function to get the...
|
by: rhepsi |
last post by:
hii all,
i have aproject where...
wen i enter a text in the textbox..., accordingly it should search in teh first name and last name of the database and display the records
How to search...
|
by: preeti13 |
last post by:
Hi friends i am here again with my probelm. i have one login page when first login on the page it is checking the active directory user exist or not if user exist then go the next page all i nee to...
|
by: dlite922 |
last post by:
I'm reading a CSV file and the firstname and last name are together separated by a space. (There could be middle name or middle initial as well, but is being ignored)
Since i'll be doing this...
|
by: mcupito |
last post by:
I have a text box where users will enter a first and last name, and then search by those parameters. I can find plenty of examples and have done search functions where first name and last name are...
|
by: hh22 |
last post by:
I want to join a patient id from a table to a first name and last name in another table, how can i do that?
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |