Reputation: 147
I have the following string:
21||10/04/2017||34390136||SOME TEXT
How can I extract, in vba, the four values divided by "||" ? (21 , 10/04/2017 , 34390136 , Some Text)
I need four string with each one of the values.
Thanks
Upvotes: 0
Views: 32
Reputation: 19837
Use the SPLIT
command to split by the delimeter:
Sub Test()
Dim MyString As String
Dim MySplit As Variant
Dim x As Long
MyString = "21||10/04/2017||34390136||SOME TEXT"
MySplit = Split(MyString, "||")
For x = LBound(MySplit) To UBound(MySplit)
MsgBox MySplit(x)
Next x
End Sub
or as single lines:
split("21||10/04/2017||34390136||SOME TEXT","||")(0)
split("21||10/04/2017||34390136||SOME TEXT","||")(1)
split("21||10/04/2017||34390136||SOME TEXT","||")(2)
split("21||10/04/2017||34390136||SOME TEXT","||")(3)
Upvotes: 1