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
191 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 51

Assisted Solution

by:Joe Winograd, EE MVE
Joe Winograd, EE MVE earned 200 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 300 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 51

Expert Comment

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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

757 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now