MrBlackd
09-09-2013, 06:38 PM
I have the macro in the code below which runs successfully for the selected cell.
I want to extend it so as to work on a selection of cells.
I have tried with the Do Loop statement but I have not managed it.
Any help would be appreciated.
Sub Splitt()
Dim splitVals As Variant
Dim totalVals, y As Long
y = InputBox("Enter the delimiter character used (e.g., comma, semicolon, space...)")
If y = 0 Then Exit Sub
splitVals = Split(ActiveCell.Value, Chr(Asc(y)))
totalVals = UBound(splitVals)
Range(Cells(ActiveCell.Row, ActiveCell.Column + 1), Cells(ActiveCell.Row, ActiveCell.Column + 1 + totalVals)).Value = splitVals
End Sub
I want to extend it so as to work on a selection of cells.
I have tried with the Do Loop statement but I have not managed it.
Any help would be appreciated.
Sub Splitt()
Dim splitVals As Variant
Dim totalVals, y As Long
y = InputBox("Enter the delimiter character used (e.g., comma, semicolon, space...)")
If y = 0 Then Exit Sub
splitVals = Split(ActiveCell.Value, Chr(Asc(y)))
totalVals = UBound(splitVals)
Range(Cells(ActiveCell.Row, ActiveCell.Column + 1), Cells(ActiveCell.Row, ActiveCell.Column + 1 + totalVals)).Value = splitVals
End Sub