Loncat ke daftar isi utama

Bagaimana cara vlookup mengembalikan beberapa nilai dalam satu sel di Excel?

Biasanya, di Excel, saat Anda menggunakan fungsi VLOOKUP, jika ada beberapa nilai yang cocok dengan kriteria, Anda bisa mendapatkan yang pertama. Tapi, terkadang, Anda ingin mengembalikan semua nilai yang sesuai yang memenuhi kriteria ke dalam satu sel seperti gambar berikut yang ditampilkan, bagaimana Anda bisa menyelesaikannya?

Vlookup untuk mengembalikan beberapa nilai ke dalam satu sel dengan fungsi TEXTJOIN (Excel 2019 dan Office 365)

Vlookup mengembalikan beberapa nilai ke dalam satu sel dengan User Defined Function

Vlookup untuk mengembalikan beberapa nilai ke dalam satu sel dengan fitur yang berguna


Vlookup untuk mengembalikan beberapa nilai ke dalam satu sel dengan fungsi TEXTJOIN (Excel 2019 dan Office 365)

Jika Anda memiliki versi Excel yang lebih tinggi seperti Excel 2019 dan Office 365, ada fungsi baru - GABUNG TEKS, dengan fungsi canggih ini, Anda dapat dengan cepat melakukan vlookup dan mengembalikan semua nilai yang cocok ke dalam satu sel.

Vlookup untuk mengembalikan semua nilai yang cocok ke dalam satu sel

Harap terapkan rumus di bawah ini ke dalam sel kosong tempat Anda ingin meletakkan hasilnya, lalu tekan Ctrl + Shift + Enter kunci bersama untuk mendapatkan hasil pertama, lalu seret gagang isian ke sel yang ingin Anda gunakan rumus ini, dan Anda akan mendapatkan semua nilai yang sesuai seperti gambar di bawah ini:

=TEXTJOIN(",",TRUE,IF($A$2:$A$11=E2,$C$2:$C$11,""))

Catatan: Dalam rumus di atas, A2: A11 adalah rentang pencarian berisi data pencarian, E2 adalah nilai pencarian, C2: C11 adalah rentang data tempat Anda ingin mengembalikan nilai yang cocok, ","adalah pemisah untuk memisahkan beberapa record.

Vlookup untuk mengembalikan semua nilai yang cocok tanpa duplikat ke dalam satu sel

Jika Anda ingin mengembalikan semua nilai yang cocok berdasarkan data pencarian tanpa duplikat, rumus di bawah ini dapat membantu Anda.

Silakan salin dan tempel rumus berikut ke dalam sel kosong, lalu tekan Ctrl + Shift + Enter kunci bersama untuk mendapatkan hasil pertama, dan kemudian salin rumus ini untuk mengisi sel lain, dan Anda akan mendapatkan semua nilai yang sesuai tanpa dulpicate seperti gambar di bawah ini:

=TEXTJOIN(",", TRUE, IF(IFERROR(MATCH($C$2:$C$11, IF(E2=$A$2:$A$11, $C$2:$C$11, ""), 0),"")=MATCH(ROW($C$2:$C$11), ROW($C$2:$C$11)), $C$2:$C$11, ""))

Catatan: Dalam rumus di atas, A2: A11 adalah rentang pencarian berisi data pencarian, E2 adalah nilai pencarian, C2: C11 adalah rentang data tempat Anda ingin mengembalikan nilai yang cocok, ","adalah pemisah untuk memisahkan beberapa record.

Vlookup mengembalikan beberapa nilai ke dalam satu sel dengan User Defined Function

Fungsi TEXTJOIN di atas hanya tersedia untuk Excel 2019 dan Office 365, jika Anda memiliki versi Excel yang lebih rendah, Anda harus menggunakan beberapa kode untuk menyelesaikan tugas ini.

Vlookup untuk mengembalikan semua nilai yang cocok ke dalam satu sel

1. Tahan ALT + F11 kunci, dan itu membuka Microsoft Visual Basic untuk Aplikasi jendela.

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

Kode VBA: Vlookup untuk mengembalikan beberapa nilai ke dalam satu sel

Function ConcatenateIf(CriteriaRange As Range, Condition As Variant, ConcatenateRange As Range, Optional Separator As String = ",") As Variant
'Updateby Extendoffice
Dim xResult As String
On Error Resume Next
If CriteriaRange.Count <> ConcatenateRange.Count Then
    ConcatenateIf = CVErr(xlErrRef)
    Exit Function
End If
For i = 1 To CriteriaRange.Count
    If CriteriaRange.Cells(i).Value = Condition Then
        xResult = xResult & Separator & ConcatenateRange.Cells(i).Value
    End If
Next i
If xResult <> "" Then
    xResult = VBA.Mid(xResult, VBA.Len(Separator) + 1)
End If
ConcatenateIf = xResult
Exit Function
End Function

3. Kemudian simpan dan tutup kode ini, kembali ke lembar kerja, dan masukkan rumus ini: =CONCATENATEIF($A$2:$A$11, E2, $C$2:$C$11, ", ") ke dalam sel kosong tertentu di mana Anda ingin menempatkan hasilnya, lalu seret gagang isian ke bawah untuk mendapatkan semua nilai yang sesuai dalam satu sel yang Anda inginkan, lihat tangkapan layar:

Catatan: Dalam rumus di atas, A2: A11 adalah rentang pencarian berisi data pencarian, E2 adalah nilai pencarian, C2: C11 adalah rentang data tempat Anda ingin mengembalikan nilai yang cocok, ","adalah pemisah untuk memisahkan beberapa record.

Vlookup untuk mengembalikan semua nilai yang cocok tanpa duplikat ke dalam satu sel

Untuk mengabaikan duplikat dalam nilai yang cocok kembali, lakukan dengan kode di bawah ini.

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

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

Kode VBA: Vlookup dan mengembalikan beberapa nilai unik yang cocok ke dalam satu sel

Function MultipleLookupNoRept(Lookupvalue As String, LookupRange As Range, ColumnNumber As Integer)
'Updateby Extendoffice
    Dim xDic As New Dictionary
    Dim xRows As Long
    Dim xStr As String
    Dim i As Long
    On Error Resume Next
    xRows = LookupRange.Rows.Count
    For i = 1 To xRows
        If LookupRange.Columns(1).Cells(i).Value = Lookupvalue Then
            xDic.Add LookupRange.Columns(ColumnNumber).Cells(i).Value, ""
        End If
    Next
    xStr = ""
    MultipleLookupNoRept = xStr
    If xDic.Count > 0 Then
        For i = 0 To xDic.Count - 1
            xStr = xStr & xDic.Keys(i) & ","
        Next
        MultipleLookupNoRept = Left(xStr, Len(xStr) - 1)
    End If
End Function

3. Setelah memasukkan kode, selanjutnya klik Tools > Referensi di tempat terbuka Microsoft Visual Basic untuk Aplikasi jendela, dan kemudian, di muncul keluar Referensi - VBAProject kotak dialog, periksa Runtime Microsoft Scripting pilihan dalam Referensi yang Tersedia kotak daftar, lihat tangkapan layar:

4. Lalu klik OK untuk menutup kotak dialog, simpan dan tutup jendela kode, kembali ke lembar kerja, dan masukkan rumus ini: =MultipleLookupNoRept(E2,$A$2:$C$11,3) into a blank cell where you want to output the result, and then drag the fill hanlde down to get all matching values, see screenshot:

Catatan: Dalam rumus di atas, A2: C11 adalah rentang data yang ingin Anda gunakan, E2 adalah nilai pencarian, angkanya 3 adalah nomor kolom yang berisi nilai yang dikembalikan.

Vlookup untuk mengembalikan beberapa nilai ke dalam satu sel dengan fitur yang berguna

 Jika Anda memiliki kami Kutools untuk Excel, Dengan yang Lanjutan Gabungkan Baris fitur, Anda dapat dengan cepat menggabungkan atau menggabungkan baris berdasarkan nilai yang sama dan melakukan beberapa perhitungan yang Anda butuhkan.

Catatan:Untuk menerapkan ini Lanjutan Gabungkan Baris, pertama, Anda harus mengunduh Kutools untuk Excel, lalu terapkan fitur dengan cepat dan mudah.

Setelah menginstal Kutools untuk Excel, lakukan hal berikut:

1. Pilih rentang data yang ingin Anda gabungkan satu data kolom berdasarkan kolom lain.

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

3. Di muncul keluar Lanjutan Gabungkan Baris kotak dialog:

  • Klik nama kolom kunci yang akan digabungkan berdasarkan, lalu klik Kunci utama
  • Kemudian klik kolom lain yang ingin Anda gabungkan datanya berdasarkan kolom kunci, dan klik Menggabungkan untuk memilih satu pemisah untuk memisahkan data gabungan.

4. Kemudian klik OK tombol, dan Anda akan mendapatkan hasil sebagai berikut:

Unduh dan uji coba gratis Kutools untuk Excel Sekarang!


Artikel yang lebih relatif:

  • Fungsi VLOOKUP Dengan Beberapa Contoh Dasar Dan Tingkat Lanjut
  • Di Excel, fungsi VLOOKUP adalah fungsi yang andal untuk sebagian besar pengguna Excel, yang digunakan untuk mencari nilai di paling kiri rentang data, dan mengembalikan nilai yang cocok di baris yang sama dari kolom yang Anda tentukan. Tutorial ini membahas tentang cara menggunakan fungsi VLOOKUP dengan beberapa contoh dasar dan lanjutan di Excel.
  • Kembalikan beberapa nilai yang cocok berdasarkan satu atau beberapa kriteria
  • Biasanya, mencari nilai tertentu dan mengembalikan item yang cocok itu mudah bagi kebanyakan dari kita dengan menggunakan fungsi VLOOKUP. Namun, pernahkah Anda mencoba mengembalikan beberapa nilai yang cocok berdasarkan satu atau lebih kriteria? Pada artikel ini, saya akan memperkenalkan beberapa rumus untuk menyelesaikan tugas kompleks ini di Excel.
  • Vlookup Dan Mengembalikan Banyak Nilai Secara Vertikal
  • Biasanya, Anda dapat menggunakan fungsi Vlookup untuk mendapatkan nilai pertama yang sesuai, tetapi terkadang Anda ingin mengembalikan semua rekaman yang cocok berdasarkan kriteria tertentu. Artikel ini, saya akan berbicara tentang cara vlookup dan mengembalikan semua nilai yang cocok secara vertikal, horizontal atau ke dalam satu sel.
  • Vlookup Dan Kembalikan Beberapa Nilai Dari Daftar Drop Down
  • Di Excel, bagaimana Anda bisa vlookup dan mengembalikan beberapa nilai yang sesuai dari daftar turun bawah, yang berarti ketika Anda memilih satu item dari daftar turun bawah, semua nilai relatifnya ditampilkan sekaligus. Artikel ini, saya akan memperkenalkan solusi selangkah demi selangkah.

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 (43)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I have created a problem.
"I" have combined a "Textjoin" end "Vlookup" to return multiple values in to one single cell.
My problem is that the formula have to have an exact value to look for and I want it to lookup an "almost" match or Partial match.

Example: I have made a schedule how we ate going to work and a D1 is working from 07:30-16:00. And to lookup D1 is not the problem, the problem is that my boss sometimes puts other stuff togeather with the D1... Like "D1 +" or "D1 meeting".
Since my formula only lookup "D1" it misses for example the "D1 +".

My formula (that I have gotten from the web) =TEXTJOIN(" och ";SANT;OM($B$3:$B$15=$C$22:$F$22;$A$3:$A$15;""))It´s in swedish so "SANT" is "TRUE" and "OM" is "IF".

How can I make the formula lookup all the cells that have some form of "D1" in it and return all those to the same cell?
No matter if it says "D1 +" or "D1 meeting" or whatever.
The reson I want this, is because the boss always leave "D1" but can add other text behind the "D1"... and just because of that, my boss messes up my formula.
This comment was minimized by the moderator on the site
Hi!
This is a great VBA-Code which could help me a lot.But when I start the Function MultipleLookupNoRept Excel crashs...I´ve got a Dataset with about 6.000 Rows (Excel 2013).... is this too much for the VBA Function?

Thanks!
This comment was minimized by the moderator on the site
Hello Mr.XXL,Sorry to hear that. The row limit for Excel 2013 is 1048576. Therefore, maybe the VBA code is the reason for the crash.
Anyway, I would love to offer you another VBA code for Vlookup To Return All Matching Values Without Duplicates Into One Cell. Please use the VBA code below:
Option Explicit

Function Lookup_concat(Search_string As String, _
Search_in_col As Range, Return_val_col As Range)

Dim i As Long
Dim temp() As Variant
Dim result As String
ReDim temp(0)

For i = 1 To Search_in_col.Count
If Search_in_col.Cells(i, 1) = Search_string Then
temp(UBound(temp)) = Return_val_col.Cells(i, 1).Value
ReDim Preserve temp(UBound(temp) + 1)
End If
Next

If temp(0) <> "" Then
ReDim Preserve temp(UBound(temp) - 1)
Unique temp
For i = LBound(temp) To UBound(temp)
result = result & " " & temp(i)
Next i
Lookup_concat = Trim(result)
Else
Lookup_concat = ""
End If

End Function

Function Unique(tempArray As Variant)

Dim coll As New Collection
Dim Value As Variant

On Error Resume Next
For Each Value In tempArray
If Len(Value) > 0 Then coll.Add Value, CStr(Value)
Next Value
On Error GoTo 0

ReDim tempArray(0)

For Each Value In coll
tempArray(UBound(tempArray)) = Value
ReDim Preserve tempArray(UBound(tempArray) + 1)
Next Value

End Function

After you insert this VBA code in the Module, please type the formula =Lookup_concat(E2,$A$2:$A$14,$C$2:$C$14) into a blank cell where you want to output the result, and then drag the fill hanlde down to get all matching values. Please see the file I uploaded in this comment. Hope it solves your problem. 
Sincerely,Mandy

This comment was minimized by the moderator on the site
Hi, Thanks so much this worked!I used it to pull dates, that populated in the serial number format (<span style="letter-spacing: 0.2px; color: inherit; font-family: inherit; font-style: inherit; font-variant-ligatures: inherit; font-variant-caps: inherit; font-weight: inherit;">Changing the format to short date format using =TEXT(A2,”mm/dd/yy”) OR =DATEVALUE(A2) are not working. Do you have any solutions?</span>
This comment was minimized by the moderator on the site
Thank you for the explanations, however the function 'MultipleLookupNoRept' does not work on my file, could you tell me if an error exists.
This comment was minimized by the moderator on the site
Hi, Hasnae,Please check if you miss the third step -  check Microsoft Scripting Runtime option in the Available References list box.

This comment was minimized by the moderator on the site
Thank you so much for the code. Is there a way I can use the code to look up multiple values from multiple sheets? I tried to combine your function with IFERROR function but it doesn't seem to work.
This comment was minimized by the moderator on the site
Can this be modified to place the sum of those values? Instead of (400 400 400 400 400 400), can it sum them to show (2400)?
This comment was minimized by the moderator on the site
How with HLookUp function?
This comment was minimized by the moderator on the site
thanks for the code. I have modified it to allow you to optionally specify your own separator, Default is " ", if you specify the separator as"#cr" it will insert a CR/LF so the values will be on a separate line in the cell. It only applies the separator if there are multiple values

Function MYVLOOKUP(pValue As String, pWorkRng As Range, pIndex As Long, Optional ByVal pSep As Variant)

' ### Returns multiple values from a table into 1 cell ###

' pValue is the key value to lookup

' WorkRng is the Table you want to look up

' pIndex is the column # for the values to be returned from the pWorkRng

' pSep (optional) is the separator to be used. if omitted then default is a space (it doesn't apply the separator for the 1st entry)

' if the separtor = "#cr" it will separate the values on different line in the cell

Dim rng As Range

Dim sSep As String

Dim xResult As String

Dim Item1 As Boolean

Item1 = True



If IsMissing(pSep) = True Then

sSep = vbCr

Else

If pSep = "#cr" Then

sSep = vbCrLf

Else

sSep = pSep

End If

End If



xResult = ""

For Each rng In pWorkRng

If rng = pValue Then

If Item1 Then

xResult = xResult & rng.Offset(0, pIndex - 1)

Item1 = False

Else

xResult = xResult & sSep & rng.Offset(0, pIndex - 1)

End If

End If

Next

MYVLOOKUP = xResult

End Function
This comment was minimized by the moderator on the site
Thank you for this, the line breaks are what i needed to top this formula off! Question, is there a way to modify the code so that two values are compared? For example, similar to what we see with index and match, can i look for Product and Quantity columns, and based on those parameters it outputs results from the Region Column?
This comment was minimized by the moderator on the site
Thanks a lot for this code, it is very helpful. Does anyone know away to sum the values in the cell to just have at total of them.
Cheers
This comment was minimized by the moderator on the site
Hello, James, to sum values based on the corresponding items, the following article may help you, please chek it:
https://www.extendoffice.com/documents/excel/1268-excel-combine-duplicate-rows-and-sum.html
This comment was minimized by the moderator on the site
I have a server, it has connected with multiple applications. I want to compare compare two column and get the related applications details for that server.

What is the command for that.
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