Good afternoon I am thinking of using TextToColumns within a macro as I need to select an e-mail address from a cell, provided it doesn't have in it:-
The data being supplied to me comes from an external source where there may be any number of e-mail addresses (or none) any (or all) of which may contain "@nn.com" - separated by either a space or a semi-colon.
I have been working up some code that can successfully identify if the sole e-mail contains "@nn.com" or not and if the first e-mail address contains "@nn.com" but I got a bit stuck when it came to figuring out how to identify the total number of e-mail addresses and the the location of a non-"@nn.com" e-mail address if it wasn't the first one. Hence deciding to try to split the cell as I thought it would be easier to identify what I want from individual cells.
However my stumbling block is that there are variable numbers of e-mail addresses within each cell.
All right, I seem to have figured out how to count them:
Now, how to use that information to enable me to put together something like this?
Many thanks,
D€$
"@nn.com"
The data being supplied to me comes from an external source where there may be any number of e-mail addresses (or none) any (or all) of which may contain "@nn.com" - separated by either a space or a semi-colon.
I have been working up some code that can successfully identify if the sole e-mail contains "@nn.com" or not and if the first e-mail address contains "@nn.com" but I got a bit stuck when it came to figuring out how to identify the total number of e-mail addresses and the the location of a non-"@nn.com" e-mail address if it wasn't the first one. Hence deciding to try to split the cell as I thought it would be easier to identify what I want from individual cells.
However my stumbling block is that there are variable numbers of e-mail addresses within each cell.
All right, I seem to have figured out how to count them:
Code:
AtCount = -1
NextAt = 1
FirstAt = 1
Do While FirstAt <> 0
FirstAt = InStr(NextAt, Range("AG" & x), "@", vbTextCompare)
NextAt = FirstAt + 1
AtCount = AtCount + 1
Loop
Now, how to use that information to enable me to put together something like this?
Code:
Selection.TextToColumns Destination:=Range("AK30"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
Semicolon:=True, Comma:=False, Space:=True, Other:=False, FieldInfo:= _
Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7 _
, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1)), _
TrailingMinusNumbers:=True
Many thanks,
D€$