Preskoči na glavno vsebino

Kako vlookup in združiti več ustreznih vrednosti v Excelu?

Kot smo vsi vedeli, Vlookup funkcija v Excelu nam lahko pomaga poiskati vrednost in vrniti ustrezne podatke v drugem stolpcu, na splošno pa lahko prvo relativno vrednost dobi le, če je več ujemajočih se podatkov. V tem članku bom govoril o tem, kako vlookup in združiti več ustreznih vrednosti v samo eno celico ali navpični seznam.

Vlookup in vrni več ujemajočih se vrednosti navpično s formulo

Iskanje in združevanje več ujemajočih se vrednosti v celici z uporabniško določeno funkcijo

Poiščite in združite več ujemajočih se vrednosti v celici s Kutools za Excel


Recimo, da imam naslednji obseg podatkov, da dobim vse ustrezne vrednosti, ki temeljijo na določeni vrednosti navpično, kot je prikazano na spodnjem posnetku zaslona, ​​lahko uporabite matrično formulo.

doc vlookup združiti 1

1. Vnesite to formulo: =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))),"") v prazno celico, kamor želite postaviti rezultat, na primer E2, in pritisnite Ctrl + Shift + Enter tipke skupaj, da dobite relativno vrednostno vrednost na določenem merilu, glejte posnetek zaslona:

doc vlookup združiti 2

Opombe: V zgornji formuli:

A1: A16 je obseg stolpcev, ki vsebuje določeno vrednost, ki jo želite iskati;

D2 označuje določeno vrednost, ki jo želite vlookup;

B1: B16 je obseg stolpcev, iz katerega želite vrniti ustrezne podatke;

$ 1: $ 16 označuje sklic na vrstice znotraj obsega.

2. Nato izberite celico E2 in povlecite ročico za polnjenje navzdol do celic, dokler ne dobite praznih celic, vse ustrezne vrednosti pa so navedene v stolpcu, kot je prikazano na sliki spodaj:

doc vlookup združiti 3


Namesto da relativne vrednosti dobite navpično, včasih želite ujemajoče se vrednosti v eno celico in jih združiti s posebnim ločilom. V tem primeru vam lahko uslugo prikaže naslednja uporabniško določena funkcija.

1. Drži dol ALT + F11 tipke za odpiranje Microsoft Visual Basic za aplikacije okno.

2. Kliknite Vstavi > Moduliin prilepite naslednjo kodo v Moduli Okno.

Koda VBA: Poiščite in združite več ujemajočih se vrednosti v celici

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. Nato shranite in zaprite to kodo, se vrnite na delovni list in vnesite to formulo: = cusvlookup (D2, A1: B16,2) v prazno celico, kamor želite postaviti rezultat, in pritisnite Vnesite ključ, vse ustrezne vrednosti, ki temeljijo na določenih podatkih, so bile vrnjene v eno celico z ločevalnikom presledka, glej posnetek zaslona:

doc vlookup združiti 4

Opombe: V zgornji formuli: D2 označuje vrednosti celic, ki jih želite poiskati, A1: B16 je obseg podatkov, za katerega želite pridobiti podatke, število 2 je številka stolpca, iz katere naj se vrne ujemajoča se vrednost, lahko spremenite sklice na teze glede na vaše potrebe.


Če imate Kutools za Excel, Z njegovim Napredne kombinirane vrstice funkcijo, lahko to delo hitro končate z lahkoto. Ta funkcija vam lahko pomaga združiti vse ujemajoče se vrednosti z določenimi ločili na podlagi istih podatkov v drugem stolpcu.

Kutools za Excel : z več kot 300 priročnimi dodatki za Excel, ki jih lahko brezplačno preizkusite v 30 dneh.

Po namestitvi Kutools za Excel, naredite naslednje:

1. Izberite obseg podatkov, za katerega želite dobiti ustrezne vrednosti na podlagi določenih podatkov.

2. Nato kliknite Kutools > Spoji in razdeli > Napredne kombinirane vrstice, glej posnetek zaslona:

3. v Napredne kombinirane vrstice v pogovornem oknu kliknite ime stolpca, ki ga želite združiti, nato kliknite Primarni ključ gumb, glej posnetek zaslona:

doc vlookup združiti 6

4. Nato kliknite drugo ime stolpca, za katerega želite vrniti ujemajoče se vrednosti, in kliknite Združite če želite izbrati en ločilo za ločevanje združenih vrednosti, glejte posnetek zaslona:

doc vlookup združiti 7

5. In nato kliknite Ok gumb, so vse ustrezne vrednosti, ki temeljijo na enakih vrednostih, združene skupaj z določenim ločevalnikom, glejte posnetke zaslona:

doc vlookup združiti 8 2 doc vlookup združiti 9

 Prenesite in brezplačno preizkusite Kutools za Excel zdaj!


Kutools za Excel: z več kot 300 priročnimi dodatki za Excel, brezplačno preizkusite brez omejitev v 30 dneh. Prenesite in brezplačno preskusite zdaj!

Najboljša pisarniška orodja za produktivnost

🤖 Kutools AI Aide: Revolucionirajte analizo podatkov na podlagi: Inteligentna izvedba   |  Ustvari kodo  |  Ustvarite formule po meri  |  Analizirajte podatke in ustvarite grafikone  |  Prikličite funkcije Kutools...
Priljubljene funkcije: Poiščite, označite ali identificirajte dvojnike   |  Izbriši prazne vrstice   |  Združite stolpce ali celice brez izgube podatkov   |   Krog brez formule ...
Super iskanje: Več kriterijev VLookup    Multiple Value VLookup  |   VLookup na več listih   |   Nejasno iskanje ....
Napredni spustni seznam: Hitro ustvarite spustni seznam   |  Odvisni spustni seznam   |  Večkrat izberite spustni seznam ....
Upravitelj stolpcev: Dodajte določeno število stolpcev  |  Premakni stolpce  |  Preklop stanja vidnosti skritih stolpcev  |  Primerjaj obsege in stolpce ...
Predstavljene funkcije: Mrežni fokus   |  Pogled oblikovanja   |   Velika vrstica formule    Upravitelj delovnih zvezkov in listov   |  Knjižnica virov (Samodejno besedilo)   |  Izbirnik datuma   |  Združite delovne liste   |  Šifriranje/dešifriranje celic    Pošljite e-pošto po seznamu   |  Super filter   |   Poseben filter (filter krepko/ležeče/prečrtano ...) ...
15 najboljših kompletov orodij12 Besedilo Orodja (dodajanje besedila, Odstrani znake,...)   |   50 + Graf Vrste (Gantt Chart,...)   |   40+ Praktično Formule (Izračunajte starost glede na rojstni dan,...)   |   19 vstavljanje Orodja (Vstavite kodo QR, Vstavi sliko s poti,...)   |   12 Pretvorba Orodja (Številke v besede, Pretvorba valut,...)   |   7 Spoji in razdeli Orodja (Napredne kombinirane vrstice, Razdeljene celice,...)   |   ... in več

Napolnite svoje Excelove spretnosti s Kutools za Excel in izkusite učinkovitost kot še nikoli prej. Kutools za Excel ponuja več kot 300 naprednih funkcij za povečanje produktivnosti in prihranek časa.  Kliknite tukaj, če želite pridobiti funkcijo, ki jo najbolj potrebujete...

Opis


Kartica Office prinaša vmesnik z zavihki v Office in poenostavi vaše delo

  • Omogočite urejanje in branje z zavihki v Wordu, Excelu, PowerPointu, Publisher, Access, Visio in Project.
  • Odprite in ustvarite več dokumentov v novih zavihkih istega okna in ne v novih oknih.
  • Poveča vašo produktivnost za 50%in vsak dan zmanjša na stotine klikov miške za vas!
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