How to do I change last name to last intial

Ivn68

Board Regular
Joined
Aug 21, 2015
Messages
75
Inside a cell I have First name, Last name
I want to use a vba to convert a it to First name, and Last initial for a whole list of names
 
If the answer to my above question is "Yes", this should do that:
VBA Code:
Sub FixNames2()

    Dim lr As Long
    Dim cell As Range
    Dim x As Long
    
    Application.ScreenUpdating = False
    
'   Find last row in column A with data
    lr = Cells(Rows.Count, "A").End(xlUp).Row
    
'   Loop through each cell in selection
    For Each cell In Range("A2:A" & lr)
'       Locate comma and space
        x = InStr(cell, ", ")
'       If found, fix name
        If x > 0 Then cell.Value = Trim(Mid(cell, x + 1)) + ", " + Left(cell, 1)
    Next cell
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,215,250
Messages
6,123,887
Members
449,130
Latest member
lolasmith

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