Split full name to first and middle and last name with single formula

Prasad K

Board Regular
Joined
Aug 4, 2021
Messages
189
Office Version
  1. 2016
  2. 2007
Platform
  1. Windows
Is any only single formula to split full name as first and middle and last name
 
You do not need a looping macro for the functionality you asked for. Assuming cell A1 is a header cell...
VBA Code:
Sub Macro2()
  Range("A2:A" & Rows.Count).TextToColumns Range("B2"), xlDelimited, , , False, False, False, True, False
End Sub
If cell A1 is a data cell also, then you can use this instead...
VBA Code:
Sub Macro2()
  Columns("A").TextToColumns Range("B2"), xlDelimited, , , False, False, False, True, False
End Sub
Note: This macro as well as the one you have marked as the Answer do not account for two-name last names like "Della Rosa" (I went to school with someone with that last name), "da Vinci", "von Newman", and such.
 
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Do you Change macro to This:
VBA Code:
Sub Macro3()
Dim Lr As Long, i As Long, j As Long, arr As Variant
    Lr = Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To Lr
     arr = Range("A" & i).Value
     Range("B" & i).Resize(, Len(arr) - Len(Replace(arr, ",", "")) + 1).Value = Split(arr, ",")
    Next i
 End Sub
 
Upvote 0
Do you Change macro to This:
VBA Code:
Sub Macro3()
Dim Lr As Long, i As Long, j As Long, arr As Variant
    Lr = Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To Lr
     arr = Range("A" & i).Value
     Range("B" & i).Resize(, Len(arr) - Len(Replace(arr, ",", "")) + 1).Value = Split(arr, ",")
    Next i
 End Sub
Many thanks, this works perfectly. Also would it be possible for the macro to put headers on the created columns i.e. "Add1" "Add2".......
 
Upvote 0
Try This:
VBA Code:
Sub Macro3()
Dim Lr As Long, i As Long, j As Long, arr As Variant
    Lr = Range("A" & Rows.Count).End(xlUp).Row
Range("B1").Resize(,3).Value = Array("Add1","Add2","Add3")
    For i = 2 To Lr
     arr = Range("A" & i).Value
     Range("B" & i).Resize(, Len(arr) - Len(Replace(arr, ",", "")) + 1).Value = Split(arr, ",")
    Next i
 End Sub
 
Upvote 0
Try This:
VBA Code:
Sub Macro3()
Dim Lr As Long, i As Long, j As Long, arr As Variant
    Lr = Range("A" & Rows.Count).End(xlUp).Row
Range("B1").Resize(,3).Value = Array("Add1","Add2","Add3")
    For i = 2 To Lr
     arr = Range("A" & i).Value
     Range("B" & i).Resize(, Len(arr) - Len(Replace(arr, ",", "")) + 1).Value = Split(arr, ",")
    Next i
 End Sub
thank you. this works nicely.
 
Upvote 0

Forum statistics

Threads
1,215,325
Messages
6,124,252
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top