Try this:
Option Explicit
Sub SplitColumns()
Dim MyVal As String, strFIND As Range, strFIRST As Range
MyVal = Application.InputBox("Please enter the number to split by:", "Split String", 3, Type:=1)
If MyVal = "False" Then Exit Sub
Application.ScreenUpdating = False
On Error Resume Next
Set strFIND = Cells.Find(MyVal, LookIn:=xlValues, LookAt:=xlWhole)
If Not strFIND Is Nothing Then
Set strFIRST = strFIND
Do
If strFIND.Offset(, 1) <> "" Then
Rows(strFIND.Row + 1).Insert xlShiftDown
Range(strFIND.Offset(, 1), strFIND.Offset(, 1).End(xlToRight)).Cut Range("A" & strFIND.Row + 1)
End If
Set strFIND = Cells.FindNext(strFIND)
Loop Until strFIND.Address = strFIRST.Address
End If
Application.ScreenUpdating = True
End Sub
How/Where to install the macro:
1. Open up your workbook
2. Get into VB Editor (Press Alt+F11)
3. Insert a new module (Insert > Module)
4. Copy and Paste in your code (given above)
5. Get out of VBA (Press Alt+Q)
6. Save as a macro-enabled workbook
The macro is installed and ready to use. Make sure the data is onscreen starting in row 1, then press Alt-F8 and select it from the macro list.
Bookmarks