VBA/excel extract multiple strings between symbols in cell
Clash Royale CLAN TAG#URR8PPP
VBA/excel extract multiple strings between symbols in cell
I have a spreadsheet with multiple cells with a bunch of text in them. Within the text are a few words/sentences between @ symbols. There are multiple of these strings in each cell.
So for example:
Lorem ipsum dolor sit amet, @consectetur adipiscing elit@. Curabitur sapien nibh, faucibus ut odio ut, vehicula elementum nunc. @Fusce consequat risus vel dui tincidunt@ condimentum.
I need a solution to extract the @...@ strings, let's say into the adjacent column.
Edit to respond to comments: No solution could be attempt fully yet before making this post as I didn't know how to start - the main challenge seems to be around multiple @...@ strings in the text.
Other solutions I researched did not seem to work with multiple delimiters:
excel vba- extract text between 2 characters
Any solutions are appreciated.
Thanks
Data
Text To Columns
@
Please read Why is “Can someone help me?” not an actual question?.
– Mathieu Guindon
Aug 8 at 2:30
@simon: Welcome to Stack Overflow: Please take the tour and read How to ask a good question, then edit your question to include the code, expected behaviour, and what is wrong... then we can try to help
– Our Man in Bananas
Aug 8 at 8:33
I Downvoted/voted to close because you didn't include a Minimal, Complete, and Verifiable example , it looks like no attempt was made, and it looks like no research was done.
– Our Man in Bananas
Aug 8 at 8:33
@simon: please show us what you have tried
– Our Man in Bananas
Aug 8 at 8:34
1 Answer
1
Try this code
Sub Test()
Dim a, x, i As Long, ii As Long
a = Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row).Value
For i = LBound(a) To UBound(a)
x = Split(a(i, 1), " @")
For ii = 1 To UBound(x)
Cells(i, ii + 1).Value = Mid(x(ii), 1, InStr(x(ii), "@") - 1)
Next ii
Next i
End Sub
Thank you, this works partially. This splits every string with a space before the first @ delimiter. So "text text @string@." splits "string" correctly but for "text text@string@." nothing is split.
– Simon
Aug 8 at 14:44
I depended on your first example .. Try tweaking that to suit your needs
– YasserKhalil
Aug 8 at 15:14
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
You could go
Data
>Text To Columns
and split it into separate columns using@
as a delimiter.– ashleedawg
Aug 8 at 2:10