Function for finding first numeric in a text string

Jack Schweikhard

New Member
Joined
Aug 8, 2003
Messages
26
I have a text string, i.e. MAIIA0045879

the first numberic charcter, from the left, would be 0 (zero) at position 6

Is there a function that will find the first numeric character position in this string

I am accustomed to usint the "Find" function but I don't know any wild card that could be used for a numeric.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
How about this ?

Using MoreFunc.xll

=MIN(IF(ISNUMBER(SETV(FIND({1,2,3,4,5,6,7,8,9,0},A2))),GETV()))

array entered.

Another version, which I feel Aladin is going to like :biggrin:

=MATCH(TRUE,ABS(CODE(MID(A2,ROW($A$1:INDEX(A:A,LEN(A2))),1))-52.5)<5,0)


array entered as well. (No use of MoreFunc in there...)
 
Upvote 0
Just to prove Juan puts the V in MVP (not that there was any doubt), I was going down this hitious road:

=MID(A1,MIN(IF((ISNUMBER(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)+0)*ROW(INDIRECT("1:"&LEN(A1)))),ISNUMBER(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)+0)*ROW(INDIRECT("1:"&LEN(A1))))),1)+0
 
Upvote 0
Jack Schweikhard said:
I have a text string, i.e. MAIIA0045879

the first numberic charcter, from the left, would be 0 (zero) at position 6

Is there a function that will find the first numeric character position in this string

I am accustomed to usint the "Find" function but I don't know any wild card that could be used for a numeric.

Also:

=MIN(IF(ISERROR(FIND({1;2;3;4;5;6;7;8;9;0},A1)),"",FIND({1;2;3;4;5;6;7;8;9;0},A1)))

Not Array entered, nor MoreFunction needed.

Eli
 
Upvote 0
eliW said:
Also:

=MIN(IF(ISERROR(FIND({1;2;3;4;5;6;7;8;9;0},A1)),"",FIND({1;2;3;4;5;6;7;8;9;0},A1)))

Not Array entered, nor MoreFunction needed.

Eli
I'd propose then this

=MIN(IF(ISNUMBER(FIND({1,2,3,4,5,6,7,8,9,0},A2)),FIND({1,2,3,4,5,6,7,8,9,0},A2)))

which seems more logical (A number is the "expected" result, not the error)... but, MoreFunc would provide far more efficency, since the FIND() is only evaluated once...
 
Upvote 0
Thought I'd throw this in the mix. I propose it only if you are certain that your text string contains at least 1 number. If the text string is in cell A2, then the following non-array formula will also work:

=MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&{0,1,2,3,4,5,6,7,8,9}))

It can be revised to handle "the no numbers in the string" case as follows (& using MoreFunc):

=IF(SETV(MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&{0,1,2,3,4,5,6,7,8,9})))>LEN(A2),0,GETV())

However, it appears that Eli's (or Juan's variant) is probably a better solution to handle all possible cases.

--Tom
 
Upvote 0

Forum statistics

Threads
1,215,143
Messages
6,123,280
Members
449,094
Latest member
GoToLeep

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