Extract the last substring from a cell

后端 未结 9 1873
逝去的感伤
逝去的感伤 2020-12-01 07:57

I have names in a column. I need to split just the last names from that column into another column.

The last name is delimited by a space from the right side.

9条回答
  •  天命终不由人
    2020-12-01 08:28

    The answer provided by @Jean provides a working but obscure solution (although it doesn't handle trailing spaces)

    As an alternative consider a vba user defined function (UDF)

    Function RightWord(r As Range) As Variant
        Dim s As String
        s = Trim(r.Value)
        RightWord = Mid(s, InStrRev(s, " ") + 1)
    End Function
    

    Use in sheet as
    =RightWord(A2)

提交回复
热议问题