Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or
0
0
0
s2smodern

How to find position of first/last number in a text string in Excel?

For example, you have a list of text string which is a mixture of letters and numbers. If you want to find the position of the first or last number in each string, what would you do? Actually, using formula will help you quickly find the position of first/last number in a specified text string. In this tutorial, we will show you the details of dealing with this problem.

Find position of first number in text string in Excel

Find position of last number in text string in Excel


Easily separate text and number from one cell into two columns in Excel:

With Kutools for Excel’s EXTRACTNUMBERS function, you can quickly extract only numbers from the text string cells.

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download the free trial Now!


Find position of first number in text string in Excel


As the below screenshot shown, for finding positions of first numbers in the text strings, please do as follows.

1. Select the cell B2, copy and paste one of the below formula into the Formula Bar:

1). Formula 1: =MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A2&"0123456789"));

2). Formula 2: =MATCH(TRUE,ABS(CODE(MID(A2,ROW($A$1:INDEX(A:A,LEN(A2))),1))-52.5)<5,0) + Ctrl + Shift + Enter;

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

2. Then the first number position of the first string is displaying in the cell B2. Now drag the Fill Handle down to cell B7 to fill the below range.

Then all first number positions of the whole strings are listed out.


Find position of last number in text string in Excel

After finding the position of first number, we now start finding the position of last number in strings.

In this section, there are two formulas for you.

Formula 1: =MAX(IF(ISNUMBER(VALUE(MID(A2,ROW(INDIRECT("1:" & LEN(A2))),1))),ROW(INDIRECT("1:" & LEN(A2))))) + Ctrl + Shift + Enter;

Formula 2: =MAX(IFERROR(FIND({1,2,3,4,5,6,7,8,9,0},A2,ROW(INDIRECT("1:"&LEN(A2)))),0)) + Ctrl + Shift + Enter

1. Select cell B2, copy and paste one of the above formulas into the Formula Bar, then press Ctrl + Shift + Enter keys simultaneously. Then you can see the result displays in B2.

2. Select the B2, drag the Fill Handle down to cell B7 to auto fill the range.

Then you will get positions of all last numbers of the whole text string immediately.


Related articles:


Recommended Productivity Tools

Office Tab

gold star1 Bring handy tabs to Excel and other Office software, just like Chrome, Firefox and new Internet Explorer.

Kutools for Excel

gold star1 Amazing! Increase your productivity in 5 minutes. Don't need any special skills, save two hours every day!

gold star1 300 New Features for Excel, Make Excel Much Easy and Powerful:

  • Merge Cell/Rows/Columns without Losing Data.
  • Combine and Consolidate Multiple Sheets and Workbooks.
  • Compare Ranges, Copy Multiple Ranges, Convert Text to Date, Unit and Currency Conversion.
  • Count by Colors, Paging Subtotals, Advanced Sort and Super Filter,
  • More Select/Insert/Delete/Text/Format/Link/Comment/Workbooks/Worksheets Tools...

Screen shot of Kutools for Excel

btn read more      btn download     btn purchase

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
People in conversation:
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Francis · 2 months ago
    how to get this to work in powerpivot
  • To post as a guest, your comment is unpublished.
    LanaMadAboutExcel · 2 years ago
    .... and here I thought that I knew Excel well. Bravo!!!!!
  • To post as a guest, your comment is unpublished.
    George · 2 years ago
    And here is a formula for finding the position of the last numeric character in a string, but WITHOUT using an array formula:

    =MAX(SEARCH(CHAR(9),SUBSTITUTE("0123456789"&A1,{0,1,2,3,4,5,6,7,8,9},CHAR(9),LEN(A1)+10-LEN(SUBSTITUTE("0123456789"&A1,{0,1,2,3,4,5,6,7,8,9},"")))))-10

    The number 10 appearing in this formula, are due to the length of the constant string "0123456789", that is concatenated in this formula.
    • To post as a guest, your comment is unpublished.
      Datta · 1 years ago
      Hi George,

      your formula is may meet my requirement.

      I need similar formula to find out digit position in the string listed in "A" row in B row

      Required output
      8
      5
      1
      4
      3
      1 3
      2
      5 5
      6
      6 1
      7
      9
      9 1
      1 6
      0
      9 3
      0 2
      7 4
      9 3
      6 5
      5 7
      4 9
      8 10
      2 10
      0 8
      1 9
  • To post as a guest, your comment is unpublished.
    Ashabel · 2 years ago
    This was exactly what I wanted. Thank you.
  • To post as a guest, your comment is unpublished.
    Jon Adams · 2 years ago
    The function

    1). Formula 1: =MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A2&"0123456789"));

    It's absolutely what i needed and extremely cool!

    Thanks so much!

    Jon