How to break a string into substrings and save substrings into array?
I am having a situation while writing a function in excel VBA.
a variable is having a long string as below:
test = "jhon~Pass, kareem~pass, lacy~fail,Jenat~pass, milo~fail"
I want to store name in one array and the corresponding result values in another array.
Please help me, how it can be done?
String into substrings into array
Sub DoIt2()
Dim test As String
Dim arr
Dim x As Integer
test = "jhon~Pass, kareem~pass, lacy~fail,Jenat~pass, milo~fail"
arr = Split(test, ",")
ReDim arrName(LBound(arr) To UBound(arr))
ReDim arrPassFail(LBound(arr) To UBound(arr))
For x = LBound(arr) To UBound(arr)
arrName(x) = Split(arr(x), "~")(0) 'array of name
arrPassFail(x) = Split(arr(x), "~")(1) 'array of pass/fail
Next x
End Sub
Sub DoIt() test = "jhon~Pass,