Loncat ke daftar isi utama

Bagaimana cara mengekstrak angka hanya dari string teks di Excel?

doc ekstrak angka hanya 1

Pernahkah Anda ingin mengekstrak angka hanya dari daftar string di Excel? Di sini saya memperkenalkan beberapa cara bagi Anda untuk mengekstrak hanya angka dengan cepat dan mudah di Excel.

Metode 1: Ekstrak nomor hanya dari string teks dengan rumus

Metode 2: Ekstrak nomor hanya dari string teks dengan kode VBA

Metode 3: Ekstrak nomor hanya dari string teks dengan Kutools for Excel

Metode 4: Ekstrak angka desimal hanya dari string teks dengan rumus


Metode 1: Ekstrak nomor hanya dari string teks dengan rumus

Rumus panjang berikut dapat membantu Anda mengekstrak hanya angka dari string teks, lakukan seperti ini:

Pilih sel kosong tempat Anda ingin mengeluarkan nomor yang diekstrak, lalu ketikkan rumus ini: = SUMPRODUCT (MID (0 & A5, BESAR (INDEKS (ISNUMBER (- MID (A5, ROW (INDIRECT ("1:" & LEN (A5))), 1)) * ROW (TIDAK LANGSUNG ("1:" & LEN (A5) )), 0), BARIS (TIDAK LANGSUNG ("1:" & LEN (A5)))) + 1, 1) * 10 ^ ROW (TIDAK LANGSUNG ("1:" & LEN (A5))) / 10), lalu seret gagang isian untuk mengisi rentang yang Anda perlukan untuk menerapkan rumus ini. Lihat tangkapan layar:

doc ekstrak angka hanya 2

Catatan:

  • 1. A5 berdiri data pertama yang ingin Anda ekstrak angka hanya dari daftar.
  • 2. Hasilnya akan ditampilkan sebagai 0 jika tidak ada angka dalam string.

Ekstrak angka hanya dari string teks:

Dengan Kutools untuk Excel'S EKSTRAKNUMBER fungsi, Anda dapat dengan cepat mengekstrak hanya angka dari sel string teks. Klik untuk mengunduh Kutools for Excel!

doc ekstrak angka hanya 14


Metode 2: Ekstrak nomor hanya dari string teks dengan kode VBA

Berikut adalah kode VBA yang juga dapat membantu Anda, lakukan hal berikut:

1. Tahan Alt + F11 kunci untuk membuka Microsoft Visual Basic untuk Aplikasi jendela.

2. Klik Menyisipkan > Modul, dan tempel kode berikut di Modul Jendela.

Kode VBA: Ekstrak nomor hanya dari string teks:

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. Lalu, tekan F5 kunci untuk menjalankan kode ini, dan kotak prompt muncul untuk mengingatkan memilih rentang teks yang ingin Anda gunakan, lihat tangkapan layar:

doc ekstrak angka hanya 3

4. Lalu klik OK, kotak prompt lain mengikuti, pilih sel untuk menampilkan hasilnya, lihat tangkapan layar:

doc ekstrak angka hanya 4

5. Terakhir, klik OK tombol, dan semua nomor di sel yang dipilih telah diekstraksi sekaligus.


Metode 3: Ekstrak nomor hanya dari string teks dengan Kutools for Excel

Kutools untuk Excel juga memiliki fungsi yang kuat yang disebut EKSTRAKNUMBER, dengan fungsi ini, Anda dapat dengan cepat mengekstrak hanya angka dari string teks asli.

Kutools untuk Excel : dengan lebih dari 300 add-in Excel yang praktis, gratis untuk dicoba tanpa batasan dalam 30 hari

Setelah menginstal Kutools untuk Excel, lakukan hal berikut:

1. Klik sel di samping string teks Anda di mana Anda akan meletakkan hasilnya, lihat tangkapan layar:

doc ekstrak angka hanya 5

2. Lalu klik Kutools > Fungsi Kutools > Teks > EKSTRAKNUMBER, lihat tangkapan layar:

doc ekstrak angka hanya 6

3. di Argumen Fungsi dialog, pilih sel yang ingin Anda ekstrak nomornya dari Txt kotak teks, lalu enter benar or palsu ke dalam N kotak teks, lihat tangkapan layar:

doc ekstrak angka hanya 7

Note: argumen N adalah item opsional, jika Anda masuk benar, ini akan mengembalikan angka sebagai numerik, jika Anda memasukkan palsu, ini akan mengembalikan angka sebagai format teks, defaultnya salah, jadi Anda dapat membiarkannya kosong.

4. Dan kemudian klik OK, nomor telah diekstrak dari sel yang dipilih, lalu seret gagang isian ke sel yang ingin Anda terapkan fungsi ini, Anda akan mendapatkan hasil sebagai berikut:

doc ekstrak angka hanya 8

Klik untuk Mengunduh dan uji coba gratis Kutools for Excel Sekarang!


Metode 4: Ekstrak angka desimal hanya dari string teks dengan rumus

Jika string teks yang menyertakan beberapa angka desimal di lembar kerja Anda, bagaimana Anda bisa mengekstrak hanya angka desimal dari string teks?

Rumus di bawah ini dapat membantu Anda mengekstrak angka desimal dari string teks dengan cepat dan mudah.

Masukkan rumus ini :=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")))), Dan kemudian isi pegangan ke sel yang ingin Anda isi rumus ini, semua angka desimal telah diekstraksi dari string teks, lihat tangkapan layar:

doc ekstrak angka hanya 13


Ekstrak nomor hanya dari string dengan Kutools for Excel

Kutools untuk Excel: dengan lebih dari 300 add-in Excel yang praktis, gratis untuk dicoba tanpa batasan dalam 30 hari. Unduh dan uji coba gratis Sekarang!

Artikel Relatif:

Alat Produktivitas Kantor Terbaik

🤖 Kutools AI Ajudan: Merevolusi analisis data berdasarkan: Eksekusi Cerdas   |  Hasilkan Kode  |  Buat Rumus Khusus  |  Analisis Data dan Hasilkan Grafik  |  Aktifkan Fungsi Kutools...
Fitur Populer: Temukan, Sorot, atau Identifikasi Duplikat   |  Hapus Baris Kosong   |  Gabungkan Kolom atau Sel tanpa Kehilangan Data   |   Putaran tanpa Formula ...
Pencarian Super: VLookup Beberapa Kriteria    VLookup Nilai Berganda  |   VLookup di Beberapa Lembar   |   Pencarian Fuzzy ....
Daftar Drop-down Lanjutan: Buat Daftar Drop Down dengan Cepat   |  Daftar Drop Down yang Bergantung   |  Multi-pilih Drop Down List ....
Manajer Kolom: Tambahkan Jumlah Kolom Tertentu  |  Pindahkan Kolom  |  Alihkan Status Visibilitas Kolom Tersembunyi  |  Bandingkan Rentang & Kolom ...
Fitur Unggulan: Fokus Kisi   |  Tampilan Desain   |   Bar Formula Besar    Manajer Buku Kerja & Lembar   |  Perpustakaan Sumberdaya (Teks otomatis)   |  Pemetik tanggal   |  Gabungkan Lembar Kerja   |  Enkripsi/Dekripsi Sel    Kirim Email berdasarkan Daftar   |  Filter Super   |   Filter Khusus (filter tebal/miring/coret...) ...
15 Perangkat Teratas12 Teks Tools (Tambahkan Teks, Hapus Karakter, ...)   |   50 + Grafik jenis (Gantt Chart, ...)   |   40+ Praktis Rumus (Hitung usia berdasarkan ulang tahun, ...)   |   19 Insersi Tools (Masukkan Kode QR, Sisipkan Gambar dari Jalur, ...)   |   12 Konversi Tools (Angka ke Kata, Konversi Mata Uang, ...)   |   7 Gabungkan & Pisahkan Tools (Lanjutan Gabungkan Baris, Pisahkan Sel, ...)   |   ... dan banyak lagi

Tingkatkan Keterampilan Excel Anda dengan Kutools for Excel, dan Rasakan Efisiensi yang Belum Pernah Ada Sebelumnya. Kutools for Excel Menawarkan Lebih dari 300 Fitur Lanjutan untuk Meningkatkan Produktivitas dan Menghemat Waktu.  Klik Di Sini untuk Mendapatkan Fitur yang Paling Anda Butuhkan...

Deskripsi Produk


Tab Office Membawa antarmuka Tab ke Office, dan Membuat Pekerjaan Anda Jauh Lebih Mudah

  • Aktifkan pengeditan dan pembacaan tab di Word, Excel, PowerPoint, Publisher, Access, Visio, dan Project.
  • Buka dan buat banyak dokumen di tab baru di jendela yang sama, bukan di jendela baru.
  • Meningkatkan produktivitas Anda sebesar 50%, dan mengurangi ratusan klik mouse untuk Anda setiap hari!
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