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
211 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 54

Assisted Solution

by:Joe Winograd, EE MVE 2015&2016
Joe Winograd, EE MVE 2015&2016 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 54

Expert Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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,…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

628 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