Returning text from the end of a string

sobeitjedi

Board Regular
Joined
Mar 13, 2006
Messages
235
Office Version
  1. 365
Hi In column "L" I have a list of cities/countries:

Toronto, Ont., Canada
Montreal, Que., Canada
Toronto, Ont., Canada
Manchester, England, United Kingdom
New York City, New York, United States
Frankfurt, Germany
Abuja, Nigeria
Frankfurt, Germany
Manchester, England, United Kingdom
Doha, Qatar
Hanoi, Vietnam
Istanbul, Turkey
Yaounde, Cameroon
Istanbul, Turkey
Manchester, England, United Kingdom

In Column "M", I want a formula, to put the last part of this field after the comma, but I can't get the syntax right, particularly when some rows have more than one comma.

Please help!
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hey, you want the text AFTER the last comma in a string?

In M2:
=TRIM(MID(L2,1+SEARCH("|",SUBSTITUTE(L2,",","|",LEN(L2)-LEN(SUBSTITUTE(L2,",","")))),LEN(L2)))

Where I assume L2 is the first text "Toronto, Ont., Canada"

Alternatively (shorter formula):

=TRIM(RIGHT(SUBSTITUTE(L2,",",REPT(" ",LEN(L2))),LEN(L2)))
 
Last edited:
Upvote 0
=trim(right(a1,len(a1)-find("#",substitute(a1,",","#",len(a1)-len(substitute(a1,",",""))))))
 
Upvote 0

Forum statistics

Threads
1,215,338
Messages
6,124,358
Members
449,155
Latest member
ravioli44

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