Extract everything to the Right of the Right-most space in a String

DougRobertson

Active Member
Joined
Sep 22, 2009
Messages
334
Office Version
  1. 365
Platform
  1. Windows
Hello,

In the String "John Paul Jones" I'm looking for the Excel formula that would extract "Jones" - everything to the Right of the Right-most space.

Many thanks in advance,

~ DWR
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    TAD = Table.AddColumn(Source, "TAD", each Text.AfterDelimiter([raw], " ", {0, RelativePosition.FromEnd}), type text)
in
    TAD
rawTAD
John Paul JonesJones
 
Upvote 0
Give this formula a try...

=TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",99)),99))

where the formula assumes your text will be less than 99 characters long (if they could be longer, increase the 99's to a value guaranteed to be larger than your largest text string).
 
Upvote 0
Solution
And VBA Option
You text In A1 down
VBA Code:
Sub test()
    Dim i As Long
    Dim a As Variant
    a = Cells(1, 1).Resize(Cells(Rows.Count, 1).End(xlUp).Row)
    For i = 1 To UBound(a)
        a(i, 1) = Split(a(i, 1))(UBound(Split(a(i, 1))))
    Next
    Cells(1, 1).Offset(, 1).Resize(UBound(a)) = a
End Sub
 
Upvote 0
Another vba option is to do all rows at once.
Assuming data in column A and you want results in column B

VBA Code:
Sub ExtractRight()
  With Range("B1:B" & Range("A" & Rows.Count).End(xlUp).Row)
    .Value = .Offset(, -1).Value
    .Replace What:="* ", Replacement:="", LookAt:=xlPart
  End With
End Sub
 
Upvote 0
Thanks for all the help on this everyone! Rick's offering was more what I was looking for however.

Again, many thanks,

~ DWR
 
Upvote 0
Cheers. Glad you got a successful outcome. (y)

BTW, I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0

Forum statistics

Threads
1,214,392
Messages
6,119,254
Members
448,879
Latest member
oksanana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top