Note: The other languages of the website are Google-translated. Back to English
登入  \/ 
x
or
x
註冊  \/ 
x

or

如何在Excel中的文本字符串中找到第一個/最後一個數字的位置?

例如,您有一個由字母和數字組成的文本字符串列表。 如果要查找每個字符串中第一個或最後一個數字的位置,該怎麼辦? 實際上,使用公式可以幫助您快速找到指定文本字符串中第一個/最後一個數字的位置。 在本教程中,我們將向您顯示處理此問題的詳細信息。

在Excel中查找文本字符串中第一個數字的位置
在Excel中查找文本字符串中最後一個數字的位置


在Excel中查找文本字符串中第一個數字的位置


如下面的屏幕截圖所示,要在文本字符串中查找第一個數字的位置,請執行以下操作。

1.選擇單元格B2,將以下公式之一複制並粘貼到編輯欄中:

1)。 公式1: = MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A2&“ 0123456789”));

2)。 公式2: =MATCH(TRUE,ABS(CODE(MID(A2,ROW($A$1:INDEX(A:A,LEN(A2))),1))-52.5)<5,0) + 按Ctrl + 轉移 + Enter;

3)。 公式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.然後,第一個字符串的第一個數字位置顯示在單元格B2中。 現在將“填充手柄”向下拖動到單元格B7,以填充以下範圍。

然後列出整個字符串的所有第一個數字位置。


在Excel中查找文本字符串中最後一個數字的位置

找到第一個數字的位置後,我們現在開始查找字符串中最後一個數字的位置。

在本節中,有兩個公式可供您選擇。

配方1: = MAX(IF(ISNUMBER(VALUE(MID(A2,ROW(INDIRECT(“ 1:”&LEN(A2))),1))),ROW(INDIRECT(“ 1:”&LEN(A2))))) ) + 按Ctrl + 轉移 + Enter;

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

1.選擇單元格B2,將以上公式之一複制並粘貼到公式欄中,然後同時按Ctrl + Shift + Enter鍵。 然後您可以看到結果顯示在B2中。

2.選擇B2,將“填充手柄”向下拖動到單元格B7,以自動填充範圍。

然後,您將立即獲得整個文本字符串的所有最後數字的位置。


在一個單元格中輕鬆地將文本和數字從一個單元格分為兩列:

Kutools for Excel 分裂細胞 實用程序中,您可以按特定的分隔符將單元格範圍劃分為行或列,將文本和數字拆分為單元格,也可以通過certian長度拆分文本。 立即下載並嘗試! (30天免費試用)


相關文章:


最佳辦公效率工具

Kutools for Excel解決了您的大多數問題,並使您的生產率提高了80%

  • 重用: 快速插入 複雜的公式,圖表 以及您以前使用過的任何東西; 加密單元 帶密碼 創建郵件列表 並發送電子郵件...
  • 超級公式欄 (輕鬆編輯多行文本和公式); 閱讀版式 (輕鬆讀取和編輯大量單元格); 粘貼到過濾範圍...
  • 合併單元格/行/列 不會丟失數據; 拆分單元格內容; 合併重複的行/列...防止細胞重複; 比較範圍...
  • 選擇重複或唯一 行; 選擇空白行 (所有單元格都是空的); 超級查找和模糊查找 在許多工作簿中; 隨機選擇...
  • 確切的副本 多個單元格,無需更改公式參考; 自動創建參考 到多張紙; 插入項目符號,複選框等...
  • 提取文字,添加文本,按位置刪除, 刪除空間; 創建和打印分頁小計; 在單元格內容和註釋之間轉換...
  • 超級濾鏡 (將過濾方案保存並應用於其他工作表); 高級排序 按月/週/日,頻率及更多; 特殊過濾器 用粗體,斜體...
  • 結合工作簿和工作表; 根據關鍵列合併表; 將數據分割成多個工作表; 批量轉換xls,xlsx和PDF...
  • 超過300種強大功能。 支持Office / Excel 2007-2019和365。支持所有語言。 在您的企業或組織中輕鬆部署。 完整功能30天免費試用。 60天退款保證。
kte選項卡201905

Office選項卡為Office帶來了選項卡式界面,使您的工作更加輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 每天將您的工作效率提高50%,並減少數百次鼠標單擊!
officetab底部
Say something here...
symbols left.
You are guest
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.
    Mehidy Hassan · 2 months ago
    @George Many Thanks , Great
  • To post as a guest, your comment is unpublished.
    madgrappler · 1 years ago
    Thought I would let everyone know that I needed to find the last position of the house numbers in an address field in access. The only way I could do this was to export a short query to excel and run this formula. I know there is a way to get the excel functions in access but this was much easier. I had addresses that had varying house number lengths and then you throw in the 1st, 2nd, 3rd...St., Ave into the mix within the street name and you got a major problem parsing a very bad formatted address string.

    address examples 1234 nw (or NW) 4th St.
    12 West St North (or N)
    123,456, and 789 Heritage Circle (or Crc)
    123 & 456 N 1st. St

    I figured out a way to parse off the first and second example real quick with some research (I would give credit, but right now I can't remember where I got the answer). It involved creating a VBA function to accomplish it. That worked great but I came to a problem when we come to the first "," or "and" or "&".

    Using this formula in excel found the last number I needed without choosing the street number. Since most house numbers ended with a space " " between them and the direction segment or the street name segment, I added --- &" " after the find formula. Like this: in an array formula
    =MAX(IFERROR(FIND({1,2,3,4,5,6,7,8,9,0}&" ",E2,ROW(INDIRECT("1:"&LEN(E2)))),0))
    A quick export back to an access table and wala! you have the number.
    202 & 206 N Blanche Ave = 9

    Now I know I could probably parse the rest of the address in excel but it actually worked real well in Access, so I just decided to do the rest there.

    If there is a way to do it all in Access, I couldn't find it or figure it out.
  • To post as a guest, your comment is unpublished.
    Borja · 2 years ago
    goood, thanks
  • To post as a guest, your comment is unpublished.
    crystal · 2 years ago
    @Guess You are welcome O(∩_∩)O
  • To post as a guest, your comment is unpublished.
    Guess · 2 years 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.
    Wajid · 2 years ago
    @Jon Adams Hats off mate..
  • To post as a guest, your comment is unpublished.
    crystal · 2 years ago
    @Francis Hi,
    Sorry can't help with this.
  • To post as a guest, your comment is unpublished.
    Francis · 2 years ago
    how to get this to work in powerpivot
  • To post as a guest, your comment is unpublished.
    Datta · 4 years ago
    @George 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.
    LanaMadAboutExcel · 4 years ago
    .... and here I thought that I knew Excel well. Bravo!!!!!
  • To post as a guest, your comment is unpublished.
    George · 4 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.
    Ashabel · 4 years ago
    This was exactly what I wanted. Thank you.
  • To post as a guest, your comment is unpublished.
    Jon Adams · 5 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