I wanted to know if there is a way I could extract a sub string's out a string by specifying the beginning few characters and the end character.
As an example I have string like at the bottom of the question in a cell in my workbook and every cell has a similar big string. I would like to extract all the name's into an array.
The "c1-mc-" will always be a prefix for a name. I was hoping I could use a function in which I could specify that for each substring starting with "c1-mc" and ending with vbLf(enter), extract those. I think Instr() and Split() could help but not sure how to proceed.
"Str: 1/2/1
End : 1/2/2
Name: cl-mc-23223322
Name: c1-mc-dddssda
Info: alot of detail
Name: c1-asa-dddssda
task: asdf
Name: c1-mc-xd132eds"
<the code which works>
For Each rng1 In table1.DataBodyRange.Columns(8).Cells
MyString = rng1.Value
Do Until InStr(MyString, "c1-mc") = 0
namestart = InStr(MyString, "c1-mc")
name = Mid(MyString, namestart)
nameend = InStr(name, vbLf) - 1
name = Left(name, nameend) 'this gives you a name
namestart = InStr(name, "c1-mc")
name = Mid(name, namestart)
nameend = InStr(name, " ") - 1
If (nameend = -1) Then
nameend = Len(name)
End If
name = Left(name, nameend) ' gives you name incase there are no next lines
MyString = Replace(MyString, name, "") 'this cuts the original string so it now starts where the name ended.
MsgBox name
i = i + 1
Loop
Next