Vai al contenuto principale

Come visualizzare e concatenare più valori corrispondenti in Excel?

Come tutti sappiamo, il Vlookup la funzione in Excel può aiutarci a cercare un valore e restituire i dati corrispondenti in un'altra colonna, ma in generale può ottenere il primo valore relativo solo se sono presenti più dati corrispondenti. In questo articolo, parlerò di come visualizzare e concatenare più valori corrispondenti in una sola cella o in un elenco verticale.

Vlookup e restituisce più valori corrispondenti verticalmente con la formula

Visualizza e concatena più valori corrispondenti in una cella con la funzione definita dall'utente

Vlookup e concatena più valori corrispondenti in una cella con Kutools per Excel


Supponendo di avere il seguente intervallo di dati, per ottenere tutti i valori corrispondenti in base a un valore specifico verticalmente come mostrato nella seguente schermata, è possibile applicare una formula di matrice.

doc vlookup concatena 1

1. Inserisci questa formula: =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 una cella vuota in cui si desidera inserire il risultato, ad esempio E2, quindi premere CTRL + MAIUSC + INVIO chiavi insieme per ottenere la base del valore relativo su un criterio specifico, vedi screenshot:

doc vlookup concatena 2

Note:: Nella formula sopra:

A1: A16 è l'intervallo di colonne che contiene il valore specifico che desideri cercare;

D2 indica il valore specifico che desideri visualizzare;

B1: B16 è l'intervallo di colonne da cui si desidera restituire i dati corrispondenti;

$ 1: $ 16 indica il riferimento alle righe all'interno dell'intervallo.

2. Quindi seleziona la cella E2 e trascina il quadratino di riempimento verso il basso sulle celle fino a ottenere celle vuote e tutti i valori corrispondenti sono elencati nella colonna come mostrato nella seguente schermata:

doc vlookup concatena 3


Invece di ottenere i valori relativi verticalmente, a volte, vuoi i valori corrispondenti in una cella e concatenarli con un separatore specifico. In questo caso, la seguente funzione definita dall'utente potrebbe farti un favore.

1. Tenere premuto il tasto ALT + F11 chiavi per aprire il Microsoft Visual Basic, Applications Edition finestra.

2. Clic inserire > Modulie incolla il codice seguente nel file Moduli Finestra.

Codice VBA: Vlookup e concatena più valori corrispondenti in una cella

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. Quindi salva e chiudi questo codice, torna al foglio di lavoro e inserisci questa formula: = cusvlookup (D2, A1: B16,2) in una cella vuota in cui si desidera inserire il risultato e premere entrare chiave, tutti i valori corrispondenti basati su dati specifici sono stati restituiti in una cella con separatore di spazio, vedi screenshot:

doc vlookup concatena 4

Note:: Nella formula sopra: D2 indica i valori delle celle che desideri cercare, LA1: SI16 è l'intervallo di dati di cui vuoi recuperare i dati, il numero 2 è il numero della colonna da cui deve essere restituito il valore corrispondente, è possibile modificare questi riferimenti in base alle proprie necessità.


Se si dispone di Kutools for Excel, Con la sua Combina righe avanzate funzione, puoi completare rapidamente questo lavoro con facilità. Questa funzione può aiutarti a combinare tutti i valori corrispondenti con delimitatori specifici basati sugli stessi dati in un'altra colonna.

Kutools for Excel : con oltre 300 utili componenti aggiuntivi di Excel, da provare gratuitamente senza limitazioni in 30 giorni.

Dopo l'installazione Kutools for Excel, si prega di fare come segue:

1. Seleziona l'intervallo di dati a cui desideri ottenere i valori corrispondenti in base ai dati specifici.

2. Quindi fare clic Kutools > Unisci e dividi > Combina righe avanzate, vedi screenshot:

3. Nel Combina righe avanzate finestra di dialogo, fare clic sul nome della colonna su cui si desidera combinare, quindi fare clic su Chiave primaria pulsante, vedi screenshot:

doc vlookup concatena 6

4. Quindi fare clic su un altro nome di colonna in cui si desidera restituire i valori corrispondenti e fare clic Combinare per scegliere un separatore per separare i valori combinati, vedi screenshot:

doc vlookup concatena 7

5. E poi clicca Ok pulsante, tutti i valori corrispondenti basati sugli stessi valori sono stati combinati insieme a un separatore specifico, vedi screenshot:

doc vlookup concatena 8 2 doc vlookup concatena 9

 Scarica e prova gratuitamente Kutools per Excel ora!


Kutools for Excel: con più di 300 utili componenti aggiuntivi di Excel, liberi di provare senza limitazioni in 30 giorni. Scarica e prova gratuita ora!

I migliori strumenti per la produttività in ufficio

🤖 Assistente AI di Kutools: Rivoluziona l'analisi dei dati basandosi su: Esecuzione intelligente   |  Genera codice  |  Crea formule personalizzate  |  Analizzare i dati e generare grafici  |  Richiama le funzioni di Kutools...
Funzioni popolari: Trova, evidenzia o identifica i duplicati   |  Elimina righe vuote   |  Combina colonne o celle senza perdere dati   |   Round senza formula ...
Super ricerca: VLookup a criteri multipli    VLookup a valori multipli  |   VLookup su più fogli   |   Ricerca fuzzy ....
Elenco a discesa avanzato: Crea rapidamente un elenco a discesa   |  Elenco a discesa dipendente   |  Elenco a discesa a selezione multipla ....
Gestore di colonna: Aggiungi un numero specifico di colonne  |  Sposta colonne  |  Attiva/disattiva lo stato di visibilità delle colonne nascoste  |  Confronta intervalli e colonne ...
Funzionalità in primo piano: Messa a fuoco della griglia   |  Vista di progettazione   |   Grande barra delle formule    Gestore di cartelle di lavoro e fogli   |  Resource Library (Testo automatico)   |  Date picker   |  Combina fogli di lavoro   |  Crittografa/decrittografa le celle    Invia e-mail per elenco   |  Super filtro   |   Filtro speciale (filtro grassetto/corsivo/barrato...) ...
I 15 migliori set di strumenti12 Testo Strumenti (aggiungi testo, Rimuovi personaggi, ...)   |   50+ Grafico Tipi (Diagramma di Gantt, ...)   |   40+ Pratico Formule (Calcola l'età in base al compleanno, ...)   |   19 Inserimento Strumenti (Inserisci il codice QR, Inserisci immagine dal percorso, ...)   |   12 Conversione Strumenti (Numeri in parole, Conversione di valuta, ...)   |   7 Unisci e dividi Strumenti (Combina righe avanzate, Celle divise, ...)   |   ... e altro ancora

Potenzia le tue competenze di Excel con Kutools per Excel e sperimenta l'efficienza come mai prima d'ora. Kutools per Excel offre oltre 300 funzionalità avanzate per aumentare la produttività e risparmiare tempo.  Fai clic qui per ottenere la funzionalità di cui hai più bisogno...

Descrizione


Office Tab porta l'interfaccia a schede in Office e semplifica notevolmente il tuo lavoro

  • Abilita la modifica e la lettura a schede in Word, Excel, PowerPoint, Publisher, Access, Visio e Project.
  • Apri e crea più documenti in nuove schede della stessa finestra, piuttosto che in nuove finestre.
  • Aumenta la produttività del 50% e riduce ogni giorno centinaia di clic del mouse!
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