Search last occurence of character and return word that contains it

szerendipal

New Member
Joined
Nov 16, 2020
Messages
2
Office Version
  1. 2013
Platform
  1. Windows
I would like a formula that looks for a specific character in cell and returns the last word that contains it.

Example: extract the last word (string?) from A1 that contains the "." (dot) character:

A1B1
FirstName LastName 1984 1:15.84 1:07.84 21:07.84
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Welcome to the MrExcel board!

One example isn't much to go on. ;)
If the word in question is always the 2nd last word like in that example, try
Excel Formula:
=TRIM(LEFT(RIGHT(SUBSTITUTE(A1," ",REPT(" ",100)),200),100))

However, if the word in question can be located in different positions then try this.

20 11 16.xlsm
AB
1FirstName LastName 1984 1:15.84 1:07.84 21:07.84
2FirstName LastName 1984 1:15.84 1:07.841:07.84
3FirstName LastName 1984 1:15.84 1:07:84 41:15.84
Last
Cell Formulas
RangeFormula
B1:B3B1=TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND(" ",A1&" ",FIND("@",SUBSTITUTE(A1,".","@",LEN(A1)-LEN(SUBSTITUTE(A1,".",""))))-1)-1)," ",REPT(" ",100)),100))
 
Upvote 0
Solution
Welcome to the MrExcel board!

One example isn't much to go on. ;)
If the word in question is always the 2nd last word like in that example, try
Excel Formula:
=TRIM(LEFT(RIGHT(SUBSTITUTE(A1," ",REPT(" ",100)),200),100))

However, if the word in question can be located in different positions then try this.

20 11 16.xlsm
AB
1FirstName LastName 1984 1:15.84 1:07.84 21:07.84
2FirstName LastName 1984 1:15.84 1:07.841:07.84
3FirstName LastName 1984 1:15.84 1:07:84 41:15.84
Last
Cell Formulas
RangeFormula
B1:B3B1=TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND(" ",A1&" ",FIND("@",SUBSTITUTE(A1,".","@",LEN(A1)-LEN(SUBSTITUTE(A1,".",""))))-1)-1)," ",REPT(" ",100)),100))
Thanks, option 2 was exactly what I was looking for!
 
Upvote 0
You are welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,215,216
Messages
6,123,669
Members
449,114
Latest member
aides

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