Extract Text from a Text String

datastudent

Board Regular
Joined
Sep 7, 2021
Messages
65
Office Version
  1. 365
Platform
  1. Windows
Hi,

How do I extract the word "Fixed" and "Mobile" from these list.

Australia Fixed - National
Australia Mobile - National
Belgium Fixed - National
Canada Mobile - National
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hi, here's one way..
Book2
AB
1Australia Fixed - NationalFixed
2Australia Mobile - NationalMobile
3Belgium Fixed - NationalFixed
4Canada Mobile - NationalMobile
Sheet1
Cell Formulas
RangeFormula
B1:B4B1=TEXTBEFORE(TEXTAFTER(A1," ")," ")
 
Upvote 0
Hi @FormR

Thank you for your reply.

I encounter a problem with the two words country like south korea, czech republic, puerto rico, etc.
 
Upvote 0
How about
Excel Formula:
=TEXTAFTER(TRIM(TEXTBEFORE(A1,"-"))," ",-1)
 
Upvote 0
Another option (a slight tweak to my first suggestion)...
Book3
AB
1Australia Fixed - NationalFixed
2Australia Mobile - NationalMobile
3Belgium Fixed - NationalFixed
4Canada Mobile - NationalMobile
5South Korea Mobile - NationalMobile
Sheet1
Cell Formulas
RangeFormula
B1:B5B1=TEXTBEFORE(TEXTAFTER(A1," ",-3)," ")
 
Upvote 0
How about
Excel Formula:
=TEXTAFTER(TRIM(TEXTBEFORE(A1,"-"))," ",-1)
This one works for some.

I noticed just now that I also have some data in a different format like below.

Albania - Mobile - National
 
Upvote 0
Or
Excel Formula:
=TEXTAFTER(TRIM(TEXTBEFORE(A1,"-",-1))," ",-1)
 
Upvote 0
If you're only expecting either "Fixed" or "Mobile", another option would be:
Book1
AB
1Australia Fixed - NationalFixed
2Australia Mobile - NationalMobile
3Belgium Fixed - NationalFixed
4Canada Mobile - NationalMobile
5South Korea Mobile - NationalMobile
6Albania - Mobile - NationalMobile
Sheet2
Cell Formulas
RangeFormula
B1:B6B1=IF(ISNUMBER(SEARCH("fixed",A1)),"Fixed","Mobile")
 
Upvote 0
In B2 copied down.
Excel Formula:
=LET(a,SUBSTITUTE(A2," - National",""),INDEX(TEXTSPLIT(a," "),LEN(a)-LEN(SUBSTITUTE(a," ",""))+1))
 
Upvote 0

Forum statistics

Threads
1,226,089
Messages
6,188,839
Members
453,503
Latest member
MissVBAquery

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