anyone can help me with below code ? i currently working on splitting a cells value into two column , the below code can only split 1 row of the data , when i try to split the whole column of a data it doesnt work and indicate error code 13 and type mismatch , i had tried several ways like changing the datatype or the value it simply would not work . I hope anyone can help me with this ....
Option Explicit
Public Sub NameSplit()
Dim Cell As Range
Set Cell = Range("$A$1")
Dim SplitData() As String
SplitData = Split(Expression:=Cell.Value, Delimiter:=" ") 'double space as delimiter
Dim i As Long, j As Long
For i = LBound(SplitData) To UBound(SplitData)
If Trim$(SplitData(i)) <> vbNullString Then
Cell.Offset(ColumnOffset:=j).Value = Trim$(SplitData(i))
j = j + 1
End If
Next i
End Sub