メインコンテンツへスキップ

Excelでテキスト文字列からのみ数値を抽出するにはどうすればよいですか?


方法1:数式を使用してテキスト文字列からのみ数値を抽出する

次の長い数式は、テキスト文字列から数字のみを抽出するのに役立ちます。次のようにしてください。

抽出した数値を出力する空白のセルを選択し、次の数式を入力します。 = SUMPRODUCT(MID(0&A5、LARGE(INDEX(ISNUMBER(-MID(A5、ROW(INDIRECT( "1:"&LEN(A5)))、1))* ROW(INDIRECT( "1:"&LEN(A5) ))、0)、ROW(INDIRECT( "1:"&LEN(A5))))+ 1、1)* 10 ^ ROW(INDIRECT( "1:"&LEN(A5)))/ 10)、次に塗りつぶしハンドルをドラッグして、この数式を適用するために必要な範囲を塗りつぶします。 スクリーンショットを参照してください:

doc抽出番号のみ2

注意:

  • 1. A5 リストからのみ数値を抽出する最初のデータを表します。
  • 2.文字列に数字がない場合、結果は0として表示されます。

テキスト文字列からのみ数値を抽出します。

Kutools for Excelさん 抽出番号 関数を使用すると、テキスト文字列セルから数字のみをすばやく抽出できます。 クリックしてKutoolsfor Excelをダウンロードしてください!

doc抽出番号のみ14


方法2:VBAコードを使用してテキスト文字列からのみ数値を抽出する

これもあなたに有利に働くことができるVBAコードです、次のようにしてください:

1。 を押し続けます Altキー+ F11 キーを押して アプリケーション向け Microsoft Visual Basic 窓。

2に設定します。 OK をクリックします。 インセット > モジュール、次のコードをに貼り付けます モジュール 窓。

VBAコード:テキスト文字列からのみ番号を抽出します:

Sub ExtrNumbersFromRange()
    Dim xRg As Range
    Dim xDRg As Range
    Dim xRRg As Range
    Dim nCellLength As Integer
    Dim xNumber As Integer
    Dim strNumber As String
    Dim xTitleId As String
    Dim xI As Integer
    xTitleId = "KutoolsforExcel"
    Set xDRg = Application.InputBox("Please select text strings:", xTitleId, "", Type:=8)
    If TypeName(xDRg) = "Nothing" Then Exit Sub
    Set xRRg = Application.InputBox("Please select output cell:", xTitleId, "", Type:=8)
    If TypeName(xRRg) = "Nothing" Then Exit Sub
    xI = 0
    strNumber = ""
  For Each xRg In xDRg
    xI = xI + 1
    nCellLength = Len(xRg)
    For xNumber = 1 To nCellLength
      If IsNumeric(Mid(xRg, xNumber, 1)) Then
        strNumber = strNumber & Mid(xRg, xNumber, 1)
      End If
    Next xNumber
    xRRg.Item(xI) = strNumber
    strNumber = ""
  Next xRg
End Sub

3。 そして、を押します F5 このコードを実行するためのキーを押すと、使用するテキスト範囲の選択を通知するプロンプトボックスが表示されます。スクリーンショットを参照してください。

doc抽出番号のみ3

4。 次に、をクリックします。 OK、別のプロンプトボックスが続きます。結果を出力するセルを選択してください。スクリーンショットを参照してください。

doc抽出番号のみ4

5。 最後に、 OK ボタンをクリックすると、選択したセルのすべての数値が一度に抽出されます。


方法3:Kutools forExcelを使用してテキスト文字列からのみ数値を抽出する

Kutools for Excel と呼ばれる強力な機能もあります 抽出番号、この関数を使用すると、元のテキスト文字列から数字のみをすばやく抽出できます。

Kutools for Excel : 300以上の便利なExcelアドインがあり、30日以内に制限なしで無料で試すことができます

インストールした後 Kutools for Excel、次のようにしてください。

1。 結果を入力するテキスト文字列の横のセルをクリックします。スクリーンショットを参照してください。

doc抽出番号のみ5

2。 次に、をクリックします クツール > Kutoolsの機能 > テキスト > 抽出番号、スクリーンショットを参照してください:

doc抽出番号のみ6

3。 の中に 関数の引数 ダイアログで、数値を抽出するセルを選択します。 TXT テキストボックスに入力し、 true or falseN テキストボックス、スクリーンショットを参照:

doc抽出番号のみ7

Note:引数 N 入力した場合、はオプションのアイテムです true、入力すると数値が返されます false、数値をテキスト形式で返します。デフォルトはfalseなので、空白のままにすることができます。

4。 そして、 OK、選択したセルから数値が抽出された後、この関数を適用するセルまで塗りつぶしハンドルを下にドラッグすると、次の結果が得られます。

doc抽出番号のみ8

クリックしてダウンロードし、Excel用の無料トライアルKutoolsを今すぐ!


方法4:数式を使用してテキスト文字列からのみXNUMX進数を抽出する

ワークシートにいくつかのXNUMX進数を含むテキスト文字列の場合、テキスト文字列からXNUMX進数のみを抽出するにはどうすればよいでしょうか。

次の数式は、テキスト文字列からXNUMX進数をすばやく簡単に抽出するのに役立ちます。

次の式を入力してください:=LOOKUP(9.9E+307,--LEFT(MID(A5,MIN(FIND({1,2,3,4,5,6,7,8,9,0}, $A5&"1023456789")),999),ROW(INDIRECT("1:999"))))、次に、この数式を含めるセルまでハンドルを入力します。すべてのXNUMX進数がテキスト文字列から抽出されています。スクリーンショットを参照してください。

doc抽出番号のみ13


Kutools forExcelを使用して文字列からのみ数値を抽出する

Kutools for Excel:300以上の便利なExcelアドインがあり、30日以内に制限なしで無料で試すことができます。 今すぐダウンロードして無料トライアル!

関連記事:

最高のオフィス生産性向上ツール

🤖 Kutools AI アシスタント: 以下に基づいてデータ分析に革命をもたらします。 インテリジェントな実行   |  コードを生成  |  カスタム数式の作成  |  データを分析してグラフを生成する  |  Kutools関数を呼び出す...
人気の機能: 重複を検索、強調表示、または識別する   |  空白行を削除する   |  データを失わずに列またはセルを結合する   |   数式なしのラウンド ...
スーパールックアップ: 複数の基準の VLookup    複数の値の VLookup  |   複数のシートにわたる VLookup   |   ファジールックアップ ....
詳細ドロップダウン リスト: ドロップダウンリストを素早く作成する   |  依存関係のドロップダウン リスト   |  複数選択のドロップダウンリスト ....
列マネージャー: 特定の数の列を追加する  |  列の移動  |  Toggle 非表示列の表示ステータス  |  範囲と列の比較 ...
注目の機能: グリッドフォーカス   |  デザインビュー   |   ビッグフォーミュラバー    ワークブックとシートマネージャー   |  リソースライブラリ (自動テキスト)   |  日付ピッカー   |  ワークシートを組み合わせる   |  セルの暗号化/復号化    リストごとにメールを送信する   |  スーパーフィルター   |   特殊フィルター (太字/斜体/取り消し線をフィルター...) ...
上位 15 のツールセット12 テキスト ツール (テキストを追加, 文字を削除する、...)   |   50+ チャート 種類 (ガントチャート、...)   |   40+ 実用的 (誕生日に基づいて年齢を計算する、...)   |   19 挿入 ツール (QRコードを挿入, パスから画像を挿入、...)   |   12 変換 ツール (数字から言葉へ, 通貨の換算、...)   |   7 マージ&スプリット ツール (高度な結合行, 分割セル、...)   |   ... もっと

Kutools for Excel で Excel スキルを強化し、これまでにない効率を体験してください。 Kutools for Excelは、生産性を向上させ、時間を節約するための300以上の高度な機能を提供します。  最も必要な機能を入手するにはここをクリックしてください...

説明


Officeタブは、タブ付きのインターフェイスをOfficeにもたらし、作​​業をはるかに簡単にします

  • Word、Excel、PowerPointでタブ付きの編集と読み取りを有効にする、パブリッシャー、アクセス、Visioおよびプロジェクト。
  • 新しいウィンドウではなく、同じウィンドウの新しいタブで複数のドキュメントを開いて作成します。
  • 生産性を 50% 向上させ、毎日何百回もマウス クリックを減らすことができます!
Comments (61)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
how to get a extract extact numbers from text
This comment was minimized by the moderator on the site
Hi, I'm looking to list all numbers in a string before a certain character. The string has letters and numbers, so I want to remove the letters and only list the numbers that appear before the second minus sign "-". Example:MUMUT-S941-22460991e002
I want that to isolate the numbers 941 in the above example.
This comment was minimized by the moderator on the site
How to use Index instead of Indirect to extract number from string. Indirect is volatile and Index can replace it as per http://www.excelhero.com/blog/2011/03/the-imposing-index.html. Thanks Ahead!
This comment was minimized by the moderator on the site
Hello! I found the following formula to extract only the numbers from text strings in Excel very useful

SUMPRODUCT(MID(0&A5, LARGE(INDEX(ISNUMBER(--MID(A5, ROW(INDIRECT("1:"&LEN(A5))), 1)) * ROW(INDIRECT("1:"&LEN(A5))), 0), ROW(INDIRECT("1:"&LEN(A5))))+1, 1) * 10^ROW(INDIRECT("1:"&LEN(A5)))/10)

Could you explain more on this formula as it seems quite complicated? Many thanks.
This comment was minimized by the moderator on the site
Reading ID: 3151346 BeatO User ID: 239930 Name: Mahesh Phone: 9823010759 Email: City: nashik State: Maharashtra Reading: 55 Meal Time: Random Meal Type: RANDOM Reading Time: 2020-03-01 00:15:57 View user readings in Portal



I want to extract numeric no. post Reading text
This comment was minimized by the moderator on the site
Hello, how can i extract the cheque no.only from the below text

OUTWARD CLEARING CLRG CHQ DEPOSIT CHQ. NO: 000123~700320456 ABCD ARAB PLAZ BRANC Value DATE, 01/02/2020 - S79519642

i tried below formula and its working but i need to change the 1:57 by calculating how many character before the first digit plus how many digits i want to extract.
=MIN(FIND({0,1,2,3,4,5,6,7,8,9},A3&"0123456789"))+5 im using this formula to know how many characters before the first number..

=TEXTJOIN("",TRUE,IFERROR(MID(A3,ROW(INDIRECT("1:57")),1)+0,""))
This comment was minimized by the moderator on the site
=Mid(A2,find("CHQ. NO", A2)+9,6)
This comment was minimized by the moderator on the site
Hi. I wonder to know is it possible to extract from the next string '102-105+106-10605-10605 -10631-10632-10633-10634-10635+107' all values of only three digits that have sign '-' (i.e. minus) before them (or plus - doesn't matter). Then extract extract all 5-digits values with the same rule? If this is possible to do I will save many many hours of manual work that I can devote to lot's of uselful tasks.

P.S.
I know that regular expressions are able to do that, BUT... I hate their syntax, so I'm searching any other method to complete this task.

Thanks in advance.
This comment was minimized by the moderator on the site
Hi, is it possible to extract the numbers before "g", for example : 25,20,15,25,300,40

Ali Baba Dark Chocolate 25g box 12 pcs
Ali Baba Dark Chocolate 20g*24 box
Cadbury 5 Star White Chocolate 15g
Kinder 2 White Chocolate 25g*24
ALpella Biscuits W/Marshmallow300g
Alpella Chocolate 40g
This comment was minimized by the moderator on the site
did anyone answer or did you figure this out? this is exactly my problem right - even down to the letter 'g'. the problem with the formula I am using now is that it returns the first number, if there are more than one, from the string and not the number I am wishing to return.
This comment was minimized by the moderator on the site
Hi, is it possible to extract the numbers before "g", for example : 25,20,15,25,300,40


Ali Baba Dark Chocolate 25g box 12 pcs
Ali Baba Dark Chocolate 20g*24 box
Cadbury 5 Star White Chocolate 15g
Kinder 2 White Chocolate 25g*24
ALpella Biscuits W/Marshmallow300g
Alpella Chocolate 40g
This comment was minimized by the moderator on the site
can any one answer this question, how to extract the no's
This comment was minimized by the moderator on the site
You may try select the number before g in the first cell, copy and paste it in new cell. Then press CTRL + E. All the number before g will be auto generated. 

This comment was minimized by the moderator on the site
Tkssssss you saved my day :) God bless you
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations