Extract Text Only - Formula Help Pls

Arts

Well-known Member
Joined
Sep 28, 2007
Messages
782
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all

I thought I had this and I'm sure it's really simple but I can't seem to think of the solution

I need to extract the name only (drop the numbers at the end) so I have

Simon1 = Simon
Steve4 = Steve

I had the following formula =LEFT(A2,LEN(A2)-1) but this then fell apart when I came across Alan12

There is no space after the name, I haven't come across a name with three digits yet ie Simon100 but if the formula can be future proofed that would be ideal.

Any help on this is most appreciated as always.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
how about
=LEFT(A2,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&{0,1,2,3,4,5,6,7,8,9}))-1)

Book10
AB
1
2alan1alan
3alan123]alan
4simon1simon
5simon123simon
Sheet1
Cell Formulas
RangeFormula
B2:B5B2=LEFT(A2,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&{0,1,2,3,4,5,6,7,8,9}))-1)
 
Upvote 0
Solution
Thanks guys both seem to work, I would never have got there looking at those formula's! Always amazes me how complex it can get suddenly get when an extra digit needs removing (in this case)

I'll mark etaf as the solution simply as it came through first

@Sufiyan97 I did edit your formula where my data starts in row 2 as row 1 is just headers by editing the row number =LEFT(A1,AGGREGATE(15,6,SEARCH(ROW($2:$9),A1),1)-1) but this seem to throw up an error so I left it as 1, assuming I can expand the row if need be ie increase the 9 to 100.
 
Upvote 0
You're welcome.

Actually no need to increase or decrease rows, this will just work as it is.

I have updated the formula incase you need it

Excel Formula:
=LEFT(A1,AGGREGATE(15,6,SEARCH(ROW($1:$10)-1,A1&ROW($1:$10)-1),1)-1)
 
Upvote 0
You're welcome.

Actually no need to increase or decrease rows, this will just work as it is.

I have updated the formula incase you need it

Excel Formula:
=LEFT(A1,AGGREGATE(15,6,SEARCH(ROW($1:$10)-1,A1&ROW($1:$10)-1),1)-1)

Ah I see, my excel ignorance showing there...where I saw ROW function only going to row 10 assumed it was for the first 10 rows only. Thanks for the reply and updated formula!
 
Upvote 0
the row function , produces the numbers to search for
ROW($1:$10) will give 1 to 10 , and then the -1 gives 0 to 9
so a much better way then i posted with the numbers in an array FIND({0,1,2,3,4,5,6,7,8,9}
 
Upvote 0
so a much better way then i posted
I disagree that either formula suggesting ROW($1:$10) is a better way.

23 06 27.xlsm
ABC
1Simon01SimonSimon
2Steve4SteveSteve
3Steve114SteveSteve
4Steve11SteveSteve
Text
Cell Formulas
RangeFormula
B1:B4B1=LEFT(A1,AGGREGATE(15,6,SEARCH(ROW($1:$10)-1,A1),1)-1)
C1:C4C1=LEFT(A1,AGGREGATE(15,6,SEARCH(ROW($1:$10)-1,A1&ROW($1:$10)-1),1)-1)


It is not robust. Inserting any rows at the top will likely cause incorrect results to show. Example

23 06 27.xlsm
ABC
1
2
3Simon01#NUM!Simon0
4Steve4SteveSteve
5Steve114SteveSteve
6Steve11SteveSteve
Text
Cell Formulas
RangeFormula
B3:B6B3=LEFT(A3,AGGREGATE(15,6,SEARCH(ROW($3:$12)-1,A3),1)-1)
C3:C6C3=LEFT(A3,AGGREGATE(15,6,SEARCH(ROW($3:$12)-1,A3&ROW($3:$12)-1),1)-1)


The post #2 formula (which is robust against subsequent row insertion above) can be shortened/simplified a little to ..

23 06 27.xlsm
AB
1alan1alan
2alan123]alan
3simon1simon
4simon123simon
Text (2)
Cell Formulas
RangeFormula
B1:B4B1=LEFT(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789"))-1)
 
Upvote 0
Thanks for the follow up Peter! sorry for the delay in responding work duties

If any one could perhaps shed some light on the workings of the formula that would be great, I will use the evaluate tool to see what I can understand but mainly how the formula seems to work across whether there is 1 one digit after or two.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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