Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract substring

Status
Not open for further replies.

pwnawannab

Technical User
Mar 8, 2007
8
US
I have a filed in a table populated with multiple email addresses and subject lines. Each record can contain multiple entries of unique of email/subject combinations. I'd like to extract only the email string and place each individual email as a separate record in another table. Email address and subject are separated by : colon. Multiple email/subject entries are separated by a + plus. Here's an example of a single field:

name1@domain1.com:subject1+name2@domain2.com:subject2+name3@domain3.com:subject3

Some fields are empty.
Does anyone have suggestions on the best approach? code samples?

Thank you.
 
pwnawannab,
Code:
Const TestText = "name1@domain1.com:subject1+name2@domain2.com:subject2+name3@domain3.com:subject3"

Sub ParseToImmediate()
Dim strSub1() As String
Dim lngSub As Long
strSub1 = Split(TestText, "+")
For lngSub = LBound(strSub1) To UBound(strSub1)
  Debug.Print Left(strSub1(lngSub), InStr(1, strSub1(lngSub), ":") - 1)
Next lngSub
End Sub

CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top