johnmerlino
Board Regular
- Joined
- Sep 21, 2010
- Messages
- 94
Hey all,
If I have a pattern like this in column A (first name last name ampersand first name last name):
HORACIO ABREU & KARYNNA MARTINEZ
I am trying to get this:
ABREU
In other words, I want the last name on person on left.
This is what I have:
The above macro outputs this:
ABREU & KA
thanks for response
If I have a pattern like this in column A (first name last name ampersand first name last name):
HORACIO ABREU & KARYNNA MARTINEZ
I am trying to get this:
ABREU
In other words, I want the last name on person on left.
This is what I have:
Code:
Sub GetName()
Dim lngLastRow As Long
Dim i
lngLastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To lngLastRow
pos = InStr(Range("A" & i), " & ")
main_name = Mid(Range("A" & i).Value, 1, pos - 1)
'Value = Mid(Range("A" & i).Value, InStrRev(Trim(main_name), " ") + 1, pos - 4)
Next i
End Sub
The above macro outputs this:
ABREU & KA
thanks for response