splitting up a string in characters
Posted by Keith on February 11, 2002 5:40 AM
I was able to split up a string in a single cell:
Private Sub CommandButton1_Click()
Range("c1") = Range("a1").Characters(1, 1).Caption
Range("d1") = Range("a1").Characters(3, 1).Caption
Range("e1") = Range("a1").Characters(5, 1).Caption
Range("f1") = Range("a1").Characters(7, 1).Caption
Range("g1") = Range("a1").Characters(9, 1).Caption
End Sub
but how would to do this for 100 or 1000 cells at the same time. Is there a formula you can put into the cells instead of using VB. Or is there a FOR loop I can use that works. Here is an example of a FOR loop that I tried but it doesn't work:
For rwIndex = 1 To 10
aCells = Worksheets("Sheet1").Cells(rwIndex, 1)
cCells = Worksheets("Sheet1").Cells(rwIndex, 3)
dCells = Worksheets("Sheet1").Cells(rwIndex, 4)
eCells = Worksheets("Sheet1").Cells(rwIndex, 5)
fCells = Worksheets("Sheet1").Cells(rwIndex, 6)
gCells = Worksheets("Sheet1").Cells(rwIndex, 7)
cCells = aCells.Characters(1, 1).Text
dCells = aCells.Characters(3, 1).Text
eCells = aCells.Characters(5, 1).Text
fCells = aCells.Characters(7, 1).Text
gCells = aCells.Characters(9, 1).Text
Next rwIndex
Thank you for all your help.
- Keith