Forum Discussion
zander140
Jun 19, 2022Copper Contributor
Splitting full name into separate columns
Hello everyone, I want to apply the below VBA code so the result of the deliminating would be in another column that is several columns away from the starting cell but in the same row. For insta...
- Jun 19, 2022
Please try this tweaked code...
Private Sub Worksheet_Change(ByVal Target As Range) Dim cel As Range Dim r As Long On Error GoTo Skip If Target.Column = 2 Then Application.EnableEvents = False For Each cel In Target.Cells If InStr(cel.Value, ",") > 0 Then r = cel.Row Range("I" & r).Value = Split(cel.Value, ",")(0) Range("J" & r).Value = Split(cel.Value, ",")(1) End If Next cel End If Skip: Application.EnableEvents = True End Sub
Subodh_Tiwari_sktneer
Jun 19, 2022Silver Contributor
Please try this tweaked code...
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cel As Range
Dim r As Long
On Error GoTo Skip
If Target.Column = 2 Then
Application.EnableEvents = False
For Each cel In Target.Cells
If InStr(cel.Value, ",") > 0 Then
r = cel.Row
Range("I" & r).Value = Split(cel.Value, ",")(0)
Range("J" & r).Value = Split(cel.Value, ",")(1)
End If
Next cel
End If
Skip:
Application.EnableEvents = True
End Sub
zander140
Jun 19, 2022Copper Contributor
Thank you so much, Subodh!
- Subodh_Tiwari_sktneerJun 19, 2022Silver Contributor
You're welcome zander140!