Manipulating a comma delimited String

  • Thread starter Thread starter Steve Roberts
  • Start date Start date
S

Steve Roberts

I have a variable that contains a string with up to 4 commas in it. I
need to split out each part of the sting into separate variables. I am not
sure where to begin. I have done this with just 1 comma but the logic I used
for that doesn't seem to apply here.

strTest = test1,test2,test3,test4,test5

Variable1 = test1
Variable2 = test2
Variable3 = test3
Variable4 = test4
Variable5 = test5

Thanks in advance for any suggestions you may have.

Steve
 
Dim varSplitArray As Variant
varSplitArray = Split(strTest, ",")
Variable1 = varSplitArray(0)
Variable2 = varSplitArray(1)
Variable3 = varSplitArray(2)
Variable4 = varSplitArray(3)
Variable5 = varSplitArray(4)
 
Thanks that did it. That is the first time I have used an array and the
split function. Very cool!
 
Back
Top