View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_1530_] Rick Rothstein \(MVP - VB\)[_1530_] is offline
external usenet poster
 
Posts: 1
Default Replace "FIRSTNAME LASTNAME" with "LAST"

With VBA:

Sub lastname()
s = Split(ActiveCell.Value, " ")
u = UBound(s)
MsgBox (Left(s(u), 4))
End Sub


Another way...

MsgBox Left(Mid(ActiveCell.Value, InStrRev(ActiveCell.Value, " ") + 1), 4)

Rick