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

or

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!

Office Tab Enable Tabbed Editing and Browsing in Office, and Make Your Work Much Easier...
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
  • Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
  • More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words...
  • Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum...
  • Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns...
  • Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Create Mailing List and Send Emails by Cell's Value...
  • Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
  • More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.

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:


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Borja · 6 months ago
    goood, thanks
  • To post as a guest, your comment is unpublished.
    Guess · 8 months ago
    That's what I needed =MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A2&"0123456789"));

    thank you very much!
  • To post as a guest, your comment is unpublished.
    Francis · 1 years 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 · 3 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 · 2 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 · 3 years ago
    This was exactly what I wanted. Thank you.
  • To post as a guest, your comment is unpublished.
    Jon Adams · 3 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