Sub FixNames()
Dim cell As Range
Dim x As Long
Application.ScreenUpdating = False
' Loop through each cell in selection
For Each cell In Selection
' Locate comma and space
x = InStr(cell, ", ")
' If found, remove end of last name
If x > 0 Then cell.Value = Left(cell, x + 2)
Next cell
Application.ScreenUpdating = True
End Sub
Do I copy the whole thing or the green part is explaining what's happening
If my assumption above is true, simply select the entries you want to update and run this code:
VBA Code:Sub FixNames() Dim cell As Range Dim x As Long Application.ScreenUpdating = False ' Loop through each cell in selection For Each cell In Selection ' Locate comma and space x = InStr(cell, ", ") ' If found, remove end of last name If x > 0 Then cell.Value = Left(cell, x + 2) Next cell Application.ScreenUpdating = True End Sub
Sub FixNames()
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, remove end of last name
If x > 0 Then cell.Value = Left(cell, x + 2)
Next cell
Application.ScreenUpdating = True
End Sub