Ga naar hoofdinhoud

Hoe meerdere overeenkomstige waarden in Excel opvullen en samenvoegen?

Zoals we allemaal weten, is de Vlookup functie in Excel kan ons helpen een waarde op te zoeken en de bijbehorende gegevens in een andere kolom te retourneren, maar in het algemeen kan het alleen de eerste relatieve waarde krijgen als er meerdere overeenkomende gegevens zijn. In dit artikel zal ik het hebben over het opvouwen en samenvoegen van meerdere overeenkomstige waarden in slechts één cel of een verticale lijst.

Vlookup en retourneer meerdere overeenkomende waarden verticaal met de formule

Vlookup en voeg meerdere overeenkomende waarden in een cel samen met door de gebruiker gedefinieerde functie

Vlookup en voeg meerdere overeenkomende waarden in een cel samen met Kutools voor Excel


Stel dat ik het volgende gegevensbereik heb, om alle corresponderende waarden verticaal op basis van een specifieke waarde te krijgen, zoals in het onderstaande screenshot, kunt u een matrixformule toepassen.

doc vlookup aaneenschakelen 1

1. Voer deze formule in: =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))),"") in een lege cel waar u het resultaat wilt plaatsen, bijvoorbeeld E2, en druk vervolgens op Ctrl + Shift + Enter toetsen samen om de relatieve waarde op basis van een specifiek criterium te krijgen, zie screenshot:

doc vlookup aaneenschakelen 2

Note: In de bovenstaande formule:

A1: A16 is het kolombereik dat de specifieke waarde bevat waarnaar u wilt zoeken;

D2 geeft de specifieke waarde aan die u wilt opvullen;

B1: B16 is het kolombereik waaruit u de overeenkomstige gegevens wilt retourneren;

$ 1: $ 16 geeft de rijverwijzing binnen het bereik aan.

2. Selecteer vervolgens cel E2 en sleep de vulgreep naar beneden naar de cellen totdat u lege cellen krijgt en alle overeenkomende waarden worden in de kolom weergegeven als in het volgende screenshot:

doc vlookup aaneenschakelen 3


In plaats van de relatieve waarden verticaal op te halen, wilt u soms de overeenkomende waarden in één cel samenvoegen met een specifiek scheidingsteken. In dit geval kan de volgende door de gebruiker gedefinieerde functie u een plezier doen.

1. Houd de toets ingedrukt ALT + F11 toetsen om de te openen Microsoft Visual Basic voor toepassingen venster.

2. Klikken Invoegen > Moduleen plak de volgende code in het Module Venster.

VBA-code: Vlookup en voeg meerdere overeenkomende waarden in een cel samen

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. Sla vervolgens deze code op en sluit deze, ga terug naar het werkblad en voer deze formule in: = cusvlookup (D2, A1: B16,2) in een lege cel waar u het resultaat wilt plaatsen, en druk op Enter key, alle corresponderende waarden op basis van specifieke gegevens zijn geretourneerd in één cel met spatiescheidingsteken, zie screenshot:

doc vlookup aaneenschakelen 4

Note: In de bovenstaande formule: D2 geeft de celwaarden aan die u wilt opzoeken, A1: B16 is het gegevensbereik waarvoor u de gegevens wilt ophalen, het nummer 2 is het kolomnummer waaruit de overeenkomende waarde moet worden geretourneerd, u kunt deze verwijzingen naar uw behoefte wijzigen.


Als je Kutools for Excel, Met Geavanceerd Combineer rijen functie, kunt u deze taak snel en gemakkelijk voltooien. Deze functie kan u helpen om alle overeenkomende waarden te combineren met specifieke scheidingstekens op basis van dezelfde gegevens in een andere kolom.

Kutools for Excel : met meer dan 300 handige Excel-invoegtoepassingen, gratis te proberen zonder beperking in 30 dagen.

Na het installeren van Kutools for Excelgaat u als volgt te werk:

1. Selecteer het gegevensbereik waarvan u de bijbehorende waarden wilt krijgen op basis van de specifieke gegevens.

2. Dan klikken Kutools > Samenvoegen en splitsen > Geavanceerd Combineer rijen, zie screenshot:

3. In de Geavanceerd Combineer rijen dialoogvenster, klik op de kolomnaam die u wilt combineren op basis van en klik vervolgens op Hoofdsleutel knop, zie screenshot:

doc vlookup aaneenschakelen 6

4. Klik vervolgens op een andere kolomnaam waarvan u de overeenkomende waarden wilt retourneren, en klik op Combineren om een ​​scheidingsteken te kiezen om de gecombineerde waarden te scheiden, zie screenshot:

doc vlookup aaneenschakelen 7

5. En klik vervolgens op Ok knop, zijn alle corresponderende waarden op basis van dezelfde waarden gecombineerd met een specifiek scheidingsteken, zie screenshots:

doc vlookup aaneenschakelen 8 2 doc vlookup aaneenschakelen 9

 Download en gratis proef Kutools voor Excel nu!


Kutools for Excel: met meer dan 300 handige Excel-invoegtoepassingen, gratis te proberen zonder beperking in 30 dagen. Download en probeer nu gratis!

Beste Office-productiviteitstools

🤖 Kutools AI-assistent: Een revolutie teweegbrengen in de data-analyse op basis van: Intelligente uitvoering   |  Genereer code  |  Aangepaste formules maken  |  Analyseer gegevens en genereer grafieken  |  Roep Kutools-functies aan...
Populaire functies: Zoek, markeer of identificeer duplicaten   |  Verwijder lege rijen   |  Combineer kolommen of cellen zonder gegevens te verliezen   |   Ronde zonder formule ...
Super opzoeken: Meerdere criteria VLookup    VLookup met meerdere waarden  |   VOpzoeken over meerdere bladen   |   Fuzzy opzoeken ....
Geavanceerde vervolgkeuzelijst: Maak snel een vervolgkeuzelijst   |  Afhankelijke vervolgkeuzelijst   |  Multi-select vervolgkeuzelijst ....
Kolom Beheerder: Voeg een specifiek aantal kolommen toe  |  Kolommen verplaatsen  |  Schakel de zichtbaarheidsstatus van verborgen kolommen in  |  Vergelijk bereiken en kolommen ...
Uitgelichte functies: Raster focus   |  Ontwerpweergave   |   Grote formulebalk    Werkmap- en bladbeheer   |  resource Library (Auto-tekst)   |  Datumkiezer   |  Combineer werkbladen   |  Cellen coderen/decoderen    Stuur e-mails per lijst   |  Super filter   |   Speciaal filter (filter vet/cursief/doorhalen...) ...
Top 15 gereedschapsets12 Tekst Tools (toe te voegen tekst, Tekens verwijderen, ...)   |   50+ tabel Types (Gantt Chart, ...)   |   40+ Praktisch Formules (Bereken leeftijd op basis van verjaardag, ...)   |   19 Invoeging Tools (QR-code invoegen, Afbeelding invoegen vanaf pad, ...)   |   12 Camper ombouw Tools (Getallen naar woorden, Currency Conversion, ...)   |   7 Samenvoegen en splitsen Tools (Geavanceerd Combineer rijen, Gespleten cellen, ...)   |   ... en meer

Geef uw Excel-vaardigheden een boost met Kutools voor Excel en ervaar efficiëntie als nooit tevoren. Kutools voor Excel biedt meer dan 300 geavanceerde functies om de productiviteit te verhogen en tijd te besparen.  Klik hier om de functie te krijgen die u het meest nodig heeft...

Omschrijving


Office-tabblad Brengt een interface met tabbladen naar Office en maakt uw werk veel gemakkelijker

  • Schakel bewerken en lezen met tabbladen in Word, Excel, PowerPoint in, Publisher, Access, Visio en Project.
  • Open en maak meerdere documenten in nieuwe tabbladen van hetzelfde venster in plaats van in nieuwe vensters.
  • Verhoogt uw productiviteit met 50% en vermindert honderden muisklikken voor u elke dag!
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