Sub SplitNames()
Dim LR As Long, i As Long, X As Variant
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LR
With Range("A" & i)
X = Split(.Value)
.Offset(, 1).Resize(, UBound(X) + 1).Value = X
End With
Next i
End Sub
Sub foo()
Dim varArr As Variant
Dim i As Long, strArr() As String
Application.ScreenUpdating = False
With Worksheets(1)
Let varArr = .Range(.Cells(1, 1), _
.Cells(.Rows.Count, 1).End(xlUp)).Value
If IsArray(varArr) Then
For i = LBound(varArr, 1) To UBound(varArr, 1)
Let strArr() = Split(varArr(i, 1))
Let .Cells(i, 2).Resize( _
, UBound(strArr) + 1).Value = strArr
Erase strArr
Next
Else: .Cells(1, 2).Resize(, 2).Value = Split(varArr)
End If
End With
Application.ScreenUpdating = True
End Sub
I'm assuming you are referring to VoG's code (which does work like a charm) but I'm wondering what happened to Nate's suggestion of using excel's built-in functionality for this sort of job, namely 'Text to Columns'?Like a charm!
With code and assuming that the names are in column A
Code:Sub SplitNames() Dim LR As Long, i As Long, X As Variant LR = Range("A" & Rows.Count).End(xlUp).Row For i = 1 To LR With Range("A" & i) X = Split(.Value) .Offset(, 1).Resize(, UBound(X) + 1).Value = X End With Next i End Sub