The following routine splits the comma-separated contents of an active cell into strings and prints each result below the active cell. It will overwrite the cells below the active cell.
Sub SplitByComma()Dim arr AsVariantDim row AsIntegerDim col AsInteger
row = ActiveCell.row
col = ActiveCell.Column
arr = VBA.split(ActiveCell.Value,",")For i =0ToUBound(arr)
Cells(row +1+ i, col).Value =Trim(arr(i))Next i
EndSub
No comments:
Post a Comment