Extract text only

Arts

Well-known Member
Joined
Sep 28, 2007
Messages
765
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
This has been driving me crazy !!!

I have a list of countries with a number on the end (the number is always a single digit)

Ireland1
Uk3
Belgium6

What I am hoping for is a formula to remove the number and just return the text, Ireland, Uk etc. There is no space after the country.

Thanks
Arts
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
data was in d9 for me

=SUBSTITUTE(D9,RIGHT(D9,1),"")
 
Upvote 0
This has been driving me crazy !!!

I have a list of countries with a number on the end (the number is always a single digit)

Ireland1
Uk3
Belgium6

What I am hoping for is a formula to remove the number and just return the text, Ireland, Uk etc. There is no space after the country.
This should do it...

=LEFT(A1,LEN(A1)-1)
 
Upvote 0
Just as I thought it was only ever going to be one digit after the country France12 gets thrown up....

Is it possible for a formula that can be provided that can "future proof" it as such should I have a country with three digits or four that only the text will be returned. (bearing in mind to include countries with one digit, so it could be a combination of Holland12, Italy2 etc.

Thank you
Arts
 
Upvote 0
Just as I thought it was only ever going to be one digit after the country France12 gets thrown up....

Is it possible for a formula that can be provided that can "future proof" it as such should I have a country with three digits or four that only the text will be returned. (bearing in mind to include countries with one digit, so it could be a combination of Holland12, Italy2 etc.
This will work no matter how many digits are on the end...

=LEFT(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789"))-1)
 
Upvote 0
This will work no matter how many digits are on the end...

=LEFT(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789"))-1)

That is ridiculous!! (In a good way, amazing!!!) a part of me wants to ask you to break that down so I can perhaps even attempt to understand what is going on but on the surface of it, it seems incomprehensible. (am surprised a formula like that is required for something that seems relatively well I say easy but something that requires just text to be extracted)

But thank you for the formula!

Arts
 
Upvote 0
This will work no matter how many digits are on the end...

=LEFT(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789"))-1)
That is ridiculous!! (In a good way, amazing!!!) a part of me wants to ask you to break that down so I can perhaps even attempt to understand what is going on...
The FIND function's first argument is an array of constants (each possible digit) which FIND iterates through one at a time (because it is an array) and returns an array of values of the position in the text where it found each digit. We have FIND search A1&"0123456789" instead of just A1 because that makes sure FIND finds each digit (otherwise the array it returns would include error values). The MIN function examines the array of position values returned by the FIND function and returns the smallest one... remember, these are position numbers it is examining, so the smallest one corresponds to the position number of the first digit it found, no matter what that digit was. The LEFT function simply uses that position number for the first digit, subtracts one from it (so that that first digit is not included) and returns the rest (which is all the text in front of the first digit as requested).
 
Upvote 0
Thank you for the break down Rick or Lord Rick I should say... I shall try to digest, Thank you once again !
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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