TRIM or LEFT Function - Extract number until first non-numerical character

horizonflame

Board Regular
Joined
Sep 27, 2018
Messages
186
Office Version
  1. 2013
Hi All

I have some raw data in one column. The format of the cells is a number followed by either a space or text. I am looking to extract only the first number with a formula.

Thank for the help! :)
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Try:

=MAX(IFERROR(LEFT(A1,ROW(INDIRECT("1:"&LEN(A1))))+0,""))

with Contol+Shift+Enter.
 
Upvote 0
Hi,

Another option, entered normally:


Book1
AB
11 2341
21 text1
31234 34561234
41234text1234
5text1234
6text 1234
Sheet373
Cell Formulas
RangeFormula
B1=IFERROR(LOOKUP(9.99999999999999E+307,LEFT(A1,ROW($1:$99))+0),"")


Formula copied down.
 
Upvote 0
Both of those will fail for e.g. 12MARKET or 3JANE.

=-LOOKUP(1,-(LEFT(A1,ROW(INDIRECT("1:"&LEN(A1))))&"**0"))

Regards
 
Upvote 0
Original and Shorter version of my formula using your "catch" for possible Date Values:


Book1
ABC
11 23411
21 text11
31234 345612341234
41234text12341234
5text1234
6text 1234
712MARKET1212
83JANE33
Sheet373
Cell Formulas
RangeFormula
B1=IFERROR(-LOOKUP(9.99999999999999E+307,-(LEFT(A1,ROW($1:$99))&"**0")),"")
C1=IFERROR(-LOOKUP(1,-(LEFT(A1,ROW($1:$99))&"**0")),"")
 
Upvote 0
Hi jtakw,

Thanks very much. My source is a different spreadsheet so would I adapt the formula like this?

=IFERROR(-LOOKUP(9.99999999999999E+307,-(LEFT('[Spreadsheet2.xlsm]Sheet1'!$H6',ROW('[Spreadsheet2.xlsm]Sheet1'!$H6:$H$106))&"**0")),"")

Thanks
 
Upvote 0
No need for a negation algebra...

=IFERROR(LOOKUP(9.99999999999999E+307,(LEFT('[Spreadsheet2.xlsm]Sheet1'!$H6,ROW($1:$99))&"**0")+0),"")
 
Last edited:
Upvote 0
Thanks Aladin, do I need to modify the ($1:$99) with my range?

You are welcome. You don't need to modify that bit, as it might be expected to be sufficient, i.e. the length of the strings we are looking at won't exceed 99. Otherwise, we might need to invoke ROW(INDIRECT("1:"&LEN('[Spreadsheet2.xlsm]Sheet1'!$H6))) instead, not very appetizing prospect. (Note. I still hope Microsoft will come up with an appropriate function (ivec or intvector [as intimated long ago by Laurent Longré]).
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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