Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Determine the position of the first of any of the ten primary digits in an Excel text entry

Posted on 2014-01-06
4
Medium Priority
?
215 Views
Last Modified: 2014-01-21
Hello,

Does Excel (2013) have a command which will search for the position of the first number or digit in a string of text?

The command =SEARCH() will return the position of the first specified character or sequence of characters in a given cell. However, suppose you want to determine the position of the first of any of the ten primary digits (ie 0, 1, 2, 3...9) in a cell. Is there a way to do that?

For example, such a command would return the following results:

5 — for a cell containing "mT  z7DL2x Y"
8 — for a cell containing "g DqQj 3vd2AEp"
2 — for a cell containing "y4tKgu"
6 — for a cell containing "tq  k8w3a4"

and so on.

Thanks
0
Comment
Question by:Steve_Brady
  • 2
4 Comments
 
LVL 56

Assisted Solution

by:Joe Winograd, EE MVE 2015&2016
Joe Winograd, EE MVE 2015&2016 earned 800 total points
ID: 39759771
Hi Steve,

This article has your answer. Note specifically the section that says this (the previous sections are important, too):

Determine the position of the number in the alphanumeric string

Now we determine the position of the number by locating a TRUE value in the result of the decomposed string mentioned in the paragraph above. We employ the MATCH function here. The revised formula now becomes:

=MATCH(TRUE,ISNUMBER(1*MID(A1,ROW($1:$9),1)),0)

Important: You must enter this formula as an array by pressing CTRL+SHIFT+ENTER. If the string is abc123, this formula will yield 4 — that being the position of the first numeric character in the alphanumeric string.

There's more in the article after that, but this is where you can stop. :)   Regards, Joe
0
 
LVL 50

Accepted Solution

by:
barry houdini earned 1200 total points
ID: 39760014
Hello Steve, try this non-array version to find the position of the first digit in A1

=MOD(MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&1234567890)),LEN(A1)+1)

by concatenating all the digits to A1 in FIND it avoids errors. The MOD part ensures that you get zero if there are no numbers in A1

....or alternatively you can use AGGREGATE function like this

=IFERROR(AGGREGATE(15,6,FIND({1,2,3,4,5,6,7,8,9,0},A1),1),0)

In AGGREGATE, 15 denotes SMALL function and 6 means that errors generated by FIND are ignored

regards, barry
0
 

Author Closing Comment

by:Steve_Brady
ID: 39798163
Thanks
0
 
LVL 56

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
ID: 39798376
You're welcome.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question