This UDF (user defined function) extracts the last word or characters from a cell in Excel. This is done by finding the last separator (i.e. a space) before a set of words or characters in Excel and then returning what comes after that last separator. This means that you can return characters, part numbers, etc. that aren't whole words as long as there is a space, dash, comma, period, etc. before what you want to extract from the cell. The general explanation for this is that you can return the last word from a cell in Excel
This is a very easy function to use and has only two arguments, text and separator. The text argument is either actual text or a cell reference. The separator argument is an optional argument and refers to what separates the words. If you leave this argument blank, the default setting is a space.
Function GETLASTWORD(Text As String, Optional Separator As Variant)
Dim lastword As String
If IsMissing(Separator) Then
Separator = " "
End If
lastword = StrReverse(Text)
lastword = Left(lastword, InStr(1, lastword, Separator, vbTextCompare))
GETLASTWORD = StrReverse(Replace(lastword, Separator, ""))
End Function