jaminben
02-24-2012, 04:27 PM
Hello,
I've been trying to work out what the best way would be to convert a string which contains numbers seperated by coma's into individual numbers.
So my userform textbox contains something like "2,5,8,11" and I need to get the first number (2) hold this number and wait until Cell.Row = 2 then do something, get the next number (5) hold this number and wait until Cell.Row = 5 then do something etc. The userform textbox changes all the time from job to job.
I've been messing around with stuff like:
myString = "2,5,8,11"
Occurences = Len(myString) - Len(Replace(myString, ",", ""))
Which gives me the number of coma's
Position = InStr(myString, ",")
Which gives me the position of the first coma.
And finally using Mid(myString, start_position, number_of_characters)
But I don't seem to be able to combine everything :think:
Its late and I can't think of a way to do it.... anyone got any suggestions?
Thanks
I've been trying to work out what the best way would be to convert a string which contains numbers seperated by coma's into individual numbers.
So my userform textbox contains something like "2,5,8,11" and I need to get the first number (2) hold this number and wait until Cell.Row = 2 then do something, get the next number (5) hold this number and wait until Cell.Row = 5 then do something etc. The userform textbox changes all the time from job to job.
I've been messing around with stuff like:
myString = "2,5,8,11"
Occurences = Len(myString) - Len(Replace(myString, ",", ""))
Which gives me the number of coma's
Position = InStr(myString, ",")
Which gives me the position of the first coma.
And finally using Mid(myString, start_position, number_of_characters)
But I don't seem to be able to combine everything :think:
Its late and I can't think of a way to do it.... anyone got any suggestions?
Thanks