Loncat ke daftar isi utama

Bagaimana cara vlookup dan menggabungkan beberapa nilai yang sesuai di Excel?

Seperti yang kita semua ketahui, file Vlookup Fungsi di Excel dapat membantu kita mencari nilai dan mengembalikan data yang sesuai di kolom lain, tetapi secara umum, ini hanya bisa mendapatkan nilai relatif pertama jika ada beberapa data yang cocok. Pada artikel ini, saya akan berbicara tentang cara vlookup dan menggabungkan beberapa nilai yang sesuai hanya dalam satu sel atau daftar vertikal.

Vlookup dan mengembalikan beberapa nilai yang cocok secara vertikal dengan rumus

Vlookup dan menggabungkan beberapa nilai yang cocok dalam sel dengan User Defined Function

Vlookup dan gabungkan beberapa nilai yang cocok dalam sel dengan Kutools for Excel


Misalkan, saya memiliki rentang data berikut, untuk mendapatkan semua nilai yang sesuai berdasarkan nilai tertentu secara vertikal seperti gambar berikut yang ditampilkan, Anda dapat menerapkan rumus array.

doc vlookup menggabungkan 1

1. Masukkan rumus ini: =IF(COUNTIF($A$1:$A$16,$D$2)>=ROWS($1:1),INDEX($B$1:$B$16,SMALL(IF($A$1:$A$16=$D$2,ROW($1:$16)),ROW(1:1))),"") ke dalam sel kosong tempat Anda ingin meletakkan hasilnya, misalnya, E2, lalu tekan Ctrl + Shift + Enter kunci bersama untuk mendapatkan basis nilai relatif pada kriteria tertentu, lihat tangkapan layar:

doc vlookup menggabungkan 2

Note: Dalam rumus di atas:

A1: A16 adalah rentang kolom yang berisi nilai spesifik yang ingin Anda cari;

D2 menunjukkan nilai spesifik yang ingin Anda vlookup;

B1: B16 adalah rentang kolom yang datanya ingin Anda kembalikan;

$ 1: $ 16 menunjukkan referensi baris dalam rentang tersebut.

2. Kemudian pilih sel E2, dan seret gagang isian ke bawah ke sel sampai Anda mendapatkan sel kosong, dan semua nilai yang cocok dicantumkan ke dalam kolom seperti gambar berikut yang ditampilkan:

doc vlookup menggabungkan 3


Alih-alih mendapatkan nilai relatif secara vertikal, terkadang, Anda ingin nilai yang cocok menjadi satu sel dan menggabungkannya dengan pemisah tertentu. Dalam hal ini, Fungsi Buatan Pengguna berikut dapat membantu Anda.

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: Vlookup dan menggabungkan beberapa nilai yang cocok dalam satu sel

Function CusVlookup(lookupval, lookuprange As Range, indexcol As Long)
'updateby Extendoffice
Dim x As Range
Dim result As String
result = ""
For Each x In lookuprange
    If x = lookupval Then
        result = result & " " & x.Offset(0, indexcol - 1)
    End If
Next x
CusVlookup = result
End Function

3. Kemudian simpan dan tutup kode ini, kembali ke lembar kerja, dan masukkan rumus ini: = cusvlookup (D2, A1: B16,2) ke dalam sel kosong tempat Anda ingin meletakkan hasilnya, dan tekan Enter kunci, semua nilai yang sesuai berdasarkan data tertentu telah dikembalikan ke dalam satu sel dengan pemisah spasi, lihat tangkapan layar:

doc vlookup menggabungkan 4

Note: Dalam rumus di atas: D2 menunjukkan nilai sel yang ingin Anda cari, A1: B16 adalah rentang data yang ingin Anda ambil datanya, jumlahnya 2 adalah nomor kolom dari mana nilai yang cocok akan dikembalikan, Anda dapat mengubah referensi ini sesuai kebutuhan Anda.


Jika Anda memiliki Kutools untuk Excel, Dengan yang Lanjutan Gabungkan Baris fitur, Anda dapat dengan cepat menyelesaikan pekerjaan ini dengan mudah. Fitur ini dapat membantu Anda menggabungkan semua nilai yang cocok dengan pembatas tertentu berdasarkan data yang sama di kolom lain.

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. Pilih rentang data yang Anda inginkan untuk mendapatkan nilai yang sesuai berdasarkan data tertentu.

2. Lalu klik Kutools > Gabungkan & Pisahkan > Lanjutan Gabungkan Baris, lihat tangkapan layar:

3. di Lanjutan Gabungkan Baris kotak dialog, klik nama kolom yang ingin Anda gabungkan berdasarkan, lalu klik Kunci utama tombol, lihat tangkapan layar:

doc vlookup menggabungkan 6

4. Lalu klik nama kolom lain yang Anda inginkan untuk mengembalikan nilai yang cocok, dan klik Menggabungkan untuk memilih satu pemisah untuk memisahkan nilai gabungan, lihat tangkapan layar:

doc vlookup menggabungkan 7

5. Dan kemudian klik Ok tombol, semua nilai yang sesuai berdasarkan nilai yang sama telah digabungkan bersama dengan pemisah tertentu, lihat tangkapan layar:

doc vlookup menggabungkan 8 2 doc vlookup menggabungkan 9

 Unduh dan uji coba gratis Kutools untuk Excel Sekarang!


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!

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 (16)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Is there any way to get the unique "name" for "class1"
This comment was minimized by the moderator on the site
Hello, sym-john,
Maybe the below article can solve your problem, please view it:
https://www.extendoffice.com/documents/excel/3381-excel-extract-unique-values-with-criteria.html
This comment was minimized by the moderator on the site
This is working great for me - is there anyway to change it that it checks if the cell contains rather than a complete match? Basically I have a list of tasks where:
Column A: Dependencies (eg 10003 10004 10008)
Column B: Task Reference (eg 10001)
Column C: Dependent Tasks (the column for the formula result) - where it would lookup the task reference to see which rows contain it in Column A, and then list the Task Reference of those tasks.

E.g:

Row | Column A | Column B | Column C
1 | | 10001 | 10002 10003
2 | 10001 | 10002 | 10003
3 | 10001 10002 | 10003 |
This comment was minimized by the moderator on the site
you would want to use the Instr() function which will check for something in a string of text in a cell. You can also use Left() and Right() if you are looking for the starting or ending details.
This comment was minimized by the moderator on the site
The cusVlookup worked great for me. Another way to have a different separator is to wrap in two substitute functions. The first (from inside to out) replaces the first space with no space, the second replaces all other spaces with a " / " in mine. Could use "," if you want commas.
=SUBSTITUTE(SUBSTITUTE(cusVlookup(D2,Table1,2)," ","",1)," "," / ")

Also, if your lookup value isn't the first column, you can use 0 or negative numbers to go to column to the left.
=SUBSTITUTE(SUBSTITUTE(cusVlookup(D2,Table1,-1)," ","",1)," "," / ")
This comment was minimized by the moderator on the site
Hi, jeff,
Thanks for your sharing, you must be a warmhearted man.
This comment was minimized by the moderator on the site
I have to say, I have been trying to get a formula for combining multiple values and returning them to a single cell for 2 days now. This "How To" has saved me!! Thank you SO much! I would never have gotten it without your Module!
I do have 2 questions though. I have the deliminator as a comma instead of a space and because of that it starts out with a comma. Is there a way to prevent the start comma but keep the rest?
My second question is; When I use the fill handle it changes the range values as well as the cell value I want to look up. I want it to continue to change the cell number I want to look up but keep the same range values. How can I make this happen?

Thank you so much for your help!!
This comment was minimized by the moderator on the site
Is there a way to delete the duplicate values in the concatenate?
This comment was minimized by the moderator on the site
Hello, Jacob,
May be the following article can help you to solve your problem.
https://www.extendoffice.com/documents/excel/3381-excel-extract-unique-values-with-criteria.html

Please try, hope it can help you!
This comment was minimized by the moderator on the site
Is there a way to list the duplicate values only once, using the vba code and formula above? I am not sure where to put the countif>1 statement in the formula bar, or in the vba itself. Please help
This comment was minimized by the moderator on the site
you can add two extra condition to skip blank cells and to skip duplicates:For i = 1 To CriteriaRange.Count
If CriteriaRange.Cells(i).Value = Condition Then
If ConcatenateRange.Cells(i).Value <> "" Then 'SKIP BANKS
If InStr(xResult, ConcatenateRange.Cells(i).Value) = 0 Then 'SKIP IF FOUND DUPLICATE
xResult = xResult & Separator & ConcatenateRange.Cells(i).Value
End If
End If
End If
Next i
This comment was minimized by the moderator on the site
This is amazing but i am looking for something else, i have a table with RollNo StudentName sub1, sub2, sub3 ... Total Result, When I enter Rollnumber it should give a result like "SName Sub1 64, sub2 78,... Total 389, Result pass", is it possible
This comment was minimized by the moderator on the site
Loved the function for Excel 2013 but amended it slightly to change the separating character to ";" instead of " " and then remove the prefixed ";" from the concantenated values Results matching values in my example would have ;result01 or ;result01;result02 . Added the extra If Left(xResult, 1) = ";" to remove any extra ";" at the beginning of the string if it is the 1st character. I'm sure there is a neater way of doing it but it worked for me. :) Function CusVlookup(pValue As String, pWorkRng As Range, pIndex As Long) Dim rng As Range Dim xResult As String xResult = "" For Each rng In pWorkRng If rng = pValue Then xResult = xResult & ";" & rng.Offset(0, pIndex - 1) If Left(xResult, 1) = ";" Then xResult = MID(xResult,2,255) End If End If Next CusVlookup = xResult End Function
This comment was minimized by the moderator on the site
Make if condition for result if empty.

Function CusVlookup(lookupval, lookuprange As Range, indexcol As Long)
'updateby Extendoffice 20151118
Dim x As Range
Dim result As String
result = ""
For Each x In lookuprange
If x = lookupval Then
If Not result = "" Then
result = result & " " & x.Offset(0, indexcol - 1)
Else
result = x.Offset(0, indexcol - 1)
End If
Next x
CusVlookup = result
End Function
This comment was minimized by the moderator on the site
When using the cusvlookup is there a way to add the last name as well with a comma in between that might appear in Column C
This comment was minimized by the moderator on the site
How to get the result. Please help. data data1 result a 1 a1 b 2 a2 c b1 b2 c1 c2
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
Rate this post:
0   Characters
Suggested Locations