Vai al contenuto principale

Come estrarre il numero solo dalla stringa di testo in Excel?


Metodo 1: estrai il numero solo dalle stringhe di testo con la formula

La seguente formula lunga può aiutarti a estrarre solo i numeri dalle stringhe di testo, per favore fai come segue:

Seleziona una cella vuota in cui desideri visualizzare il numero estratto, quindi digita questa formula: = 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), quindi trascina la maniglia di riempimento per riempire l'intervallo necessario per applicare questa formula. Vedi screenshot:

doc estrae solo i numeri 2

Note:

  • 1. A5 si trova il primo dato che si desidera estrarre i numeri solo dall'elenco.
  • 2. Il risultato verrà mostrato come 0 quando non ci sono numeri nella stringa.

Estrai numeri solo da stringhe di testo:

Con Kutools for Excel'S NUMERI DI ESTRAZIONE funzione, puoi estrarre rapidamente solo numeri dalle celle della stringa di testo. Fai clic per scaricare Kutools per Excel!

doc estrae solo i numeri 14


Metodo 2: estrai il numero solo da stringhe di testo con codice VBA

Ecco un codice VBA che può anche farti un favore, per favore fai come segue:

1. Tieni premuto il Alt + F11 chiavi per aprire il Microsoft Visual Basic, Applications Edition finestra.

2. Clic inserire > Modulie incolla il codice seguente nel file Moduli Finestra.

Codice VBA: estrae il numero solo dalla stringa di testo:

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. E poi, premi F5 chiave per eseguire questo codice e viene visualizzata una finestra di messaggio per ricordare di selezionare l'intervallo di testo che si desidera utilizzare, vedere screenshot:

doc estrae solo i numeri 3

4. Quindi, fare clic OK, segue un'altra finestra di messaggio, seleziona una cella per visualizzare il risultato, vedi screenshot:

doc estrae solo i numeri 4

5. Finalmente, clicca OK e tutti i numeri nelle celle selezionate sono stati estratti contemporaneamente.


Metodo 3: estrai il numero solo dalla stringa di testo con Kutools per Excel

Kutools for Excel ha anche una potente funzione che viene chiamata NUMERI DI ESTRAZIONE, con questa funzione, puoi estrarre rapidamente solo i numeri dalle stringhe di testo originali.

Kutools for Excel : con oltre 300 utili componenti aggiuntivi di Excel, da provare gratuitamente senza limitazioni in 30 giorni

Dopo l'installazione Kutools for Excel, si prega di fare come segue:

1. Fai clic su una cella oltre alla stringa di testo in cui inserirai il risultato, vedi screenshot:

doc estrae solo i numeri 5

2. Quindi fare clic Kutools > Funzioni di Kutools > Testo > NUMERI DI ESTRAZIONE, vedi screenshot:

doc estrae solo i numeri 6

3. Nel Argomenti della funzione finestra di dialogo, seleziona una cella dalla quale desideri estrarre i numeri Testo casella di testo e quindi immettere vero or falso nella N casella di testo, vedi screenshot:

doc estrae solo i numeri 7

Note:: l'argomento N è un elemento opzionale, se inserisci vero, restituirà i numeri come numerici, se immessi falso, restituirà i numeri come formato di testo, il valore predefinito è falso, quindi puoi lasciarlo vuoto.

4. E poi clicca OK, i numeri sono stati estratti dalla cella selezionata, quindi trascina il quadratino di riempimento verso il basso sulle celle a cui desideri applicare questa funzione, otterrai il seguente risultato:

doc estrae solo i numeri 8

Fai clic per scaricare e provare gratuitamente Kutools per Excel ora!


Metodo 4: estrai il numero decimale solo dalla stringa di testo con la formula

Se le stringhe di testo includono alcuni numeri decimali nel tuo foglio di lavoro, come potresti estrarre solo i numeri decimali dalle stringhe di testo?

La formula seguente può aiutarti a estrarre i numeri decimali dalle stringhe di testo in modo rapido e semplice.

Inserisci questa formula :=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")))), E quindi riempire la maniglia fino alle celle in cui si desidera contenere questa formula, tutti i numeri decimali sono stati estratti dalle stringhe di testo, vedi screenshot:

doc estrae solo i numeri 13


Estrai il numero solo dalle stringhe con Kutools per Excel

Kutools for Excel: con più di 300 utili componenti aggiuntivi di Excel, liberi di provare senza limitazioni in 30 giorni. Scarica e prova gratuita ora!

Articoli relativi:

I migliori strumenti per la produttività in ufficio

🤖 Assistente AI di Kutools: Rivoluziona l'analisi dei dati basandosi su: Esecuzione intelligente   |  Genera codice  |  Crea formule personalizzate  |  Analizzare i dati e generare grafici  |  Richiama le funzioni di Kutools...
Funzioni popolari: Trova, evidenzia o identifica i duplicati   |  Elimina righe vuote   |  Combina colonne o celle senza perdere dati   |   Round senza formula ...
Super ricerca: VLookup a criteri multipli    VLookup a valori multipli  |   VLookup su più fogli   |   Ricerca fuzzy ....
Elenco a discesa avanzato: Crea rapidamente un elenco a discesa   |  Elenco a discesa dipendente   |  Elenco a discesa a selezione multipla ....
Gestore di colonna: Aggiungi un numero specifico di colonne  |  Sposta colonne  |  Attiva/disattiva lo stato di visibilità delle colonne nascoste  |  Confronta intervalli e colonne ...
Funzionalità in primo piano: Messa a fuoco della griglia   |  Vista di progettazione   |   Grande barra delle formule    Gestore di cartelle di lavoro e fogli   |  Resource Library (Testo automatico)   |  Date picker   |  Combina fogli di lavoro   |  Crittografa/decrittografa le celle    Invia e-mail per elenco   |  Super filtro   |   Filtro speciale (filtro grassetto/corsivo/barrato...) ...
I 15 migliori set di strumenti12 Testo Strumenti (aggiungi testo, Rimuovi personaggi, ...)   |   50+ Grafico Tipi (Diagramma di Gantt, ...)   |   40+ Pratico Formule (Calcola l'età in base al compleanno, ...)   |   19 Inserimento Strumenti (Inserisci il codice QR, Inserisci immagine dal percorso, ...)   |   12 Conversione Strumenti (Numeri in parole, Conversione di valuta, ...)   |   7 Unisci e dividi Strumenti (Combina righe avanzate, Celle divise, ...)   |   ... e altro ancora

Potenzia le tue competenze di Excel con Kutools per Excel e sperimenta l'efficienza come mai prima d'ora. Kutools per Excel offre oltre 300 funzionalità avanzate per aumentare la produttività e risparmiare tempo.  Fai clic qui per ottenere la funzionalità di cui hai più bisogno...

Descrizione


Office Tab porta l'interfaccia a schede in Office e semplifica notevolmente il tuo lavoro

  • Abilita la modifica e la lettura a schede in Word, Excel, PowerPoint, Publisher, Access, Visio e Project.
  • Apri e crea più documenti in nuove schede della stessa finestra, piuttosto che in nuove finestre.
  • Aumenta la produttività del 50% e riduce ogni giorno centinaia di clic del mouse!
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