I have have the following data in excel:
a, b, c d e f, g h i
with each row, representing a row and in one cell.
I would like to convert it to:
a b c d e f g h i
I am using the following macro, but I can’t get the autosize to do an insert, instead of overriding the cell values. Any help is appreciated.
Sub SplitCells() Dim i As Long With Application .Calculation = xlCalculationManual .ScreenUpdating = False For i = 1 To Selection.Rows.Count Dim splitValues As Variant splitValues = split(Selection.Rows(i).Value, ',') Selection.Rows(i).Resize(UBound(splitValues) - LBound(splitValues) + 1).Value = Application.Transpose(splitValues) Next i .Calculation = xlCalculationAutomatic .ScreenUpdating = True End With End Sub
This macro will take your data from column A and ‘extract’ it to column B. The results are shown below, feel free to cower at my graphical presentation skills 🙂
I’ve left it as non-destructive for testing purposes, and since it’s relatively easy to create a new column, populate it and delete the old column in VBA. An exercise for the reader…
Here is the macro: