Vai al contenuto principale

Come visualizzare per restituire più valori in una cella in Excel?

Normalmente, in Excel, quando si utilizza la funzione CERCA.VERT, se sono presenti più valori che corrispondono ai criteri, è possibile ottenere solo il primo. Ma, a volte, vuoi restituire tutti i valori corrispondenti che soddisfano i criteri in una cella come mostrato nella seguente schermata, come potresti risolverlo?

Vlookup per restituire più valori in una cella con la funzione TEXTJOIN (Excel 2019 e Office 365)

Vlookup per restituire più valori in una cella con la funzione definita dall'utente

Vlookup per restituire più valori in una cella con una funzione utile


Vlookup per restituire più valori in una cella con la funzione TEXTJOIN (Excel 2019 e Office 365)

Se hai la versione superiore di Excel come Excel 2019 e Office 365, c'è una nuova funzione: COLLEGAMENTO TESTO, con questa potente funzione, puoi visualizzare rapidamente e restituire tutti i valori corrispondenti in una cella.

Vlookup per restituire tutti i valori corrispondenti in una cella

Si prega di applicare la formula seguente in una cella vuota in cui si desidera inserire il risultato, quindi premere CTRL + MAIUSC + INVIO i tasti insieme per ottenere il primo risultato, quindi trascina il quadratino di riempimento verso il basso sulla cella in cui desideri utilizzare questa formula e otterrai tutti i valori corrispondenti come mostrato nell'immagine sottostante:

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

Nota: Nella formula sopra, A2: A11 è l'intervallo di ricerca che contiene i dati di ricerca, E2 è il valore di ricerca, C2: C11 è l'intervallo di dati da cui desideri restituire i valori corrispondenti, ","è il separatore per separare i record multipli.

Vlookup per restituire tutti i valori corrispondenti senza duplicati in una cella

Se desideri restituire tutti i valori corrispondenti in base ai dati di ricerca senza duplicati, la formula seguente potrebbe aiutarti.

Copia e incolla la seguente formula in una cella vuota, quindi premi CTRL + MAIUSC + INVIO le chiavi insieme per ottenere il primo risultato, quindi copia questa formula per riempire altre celle, e otterrai tutti i valori corrispondenti senza quelli delicati come mostrato nell'immagine sottostante:

=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, ""))

Nota: Nella formula sopra, A2: A11 è l'intervallo di ricerca che contiene i dati di ricerca, E2 è il valore di ricerca, C2: C11 è l'intervallo di dati da cui desideri restituire i valori corrispondenti, ","è il separatore per separare i record multipli.

Vlookup per restituire più valori in una cella con la funzione definita dall'utente

La funzione TEXTJOIN sopra è disponibile solo per Excel 2019 e Office 365, se hai altre versioni precedenti di Excel, dovresti usare alcuni codici per completare questa attività.

Vlookup per restituire tutti i valori corrispondenti in una cella

1. Tieni premuto il ALT + F11 chiavi e apre il file Microsoft Visual Basic, Applications Edition finestra.

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

Codice VBA: Vlookup per restituire più valori in una cella

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. Quindi salva e chiudi questo codice, torna al foglio di lavoro e inserisci questa formula: =CONCATENATEIF($A$2:$A$11, E2, $C$2:$C$11, ", ") in una cella vuota specifica in cui desideri posizionare il risultato, quindi trascina verso il basso la maniglia di riempimento per ottenere tutti i valori corrispondenti in una cella che desideri, vedi screenshot:

Nota: Nella formula sopra, A2: A11 è l'intervallo di ricerca che contiene i dati di ricerca, E2 è il valore di ricerca, C2: C11 è l'intervallo di dati da cui desideri restituire i valori corrispondenti, ","è il separatore per separare i record multipli.

Vlookup per restituire tutti i valori corrispondenti senza duplicati in una cella

Per ignorare i duplicati nei valori corrispondenti restituiti, eseguire il codice seguente.

1. Tieni premuto il Alt + F11 chiavi per aprire il Microsoft Visual Basic, Applications Edition finestra.

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

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

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. Dopo aver inserito il codice, fare clic su Strumenti > Riferimenti in aperto Microsoft Visual Basic, Applications Edition finestra, e poi, nel saltato fuori Riferimenti - VBAProject finestra di dialogo, controllare Runtime di script Microsoft opzione nel Riferimenti disponibili casella di riepilogo, vedere screenshot:

4. Quindi fare clic OK per chiudere la finestra di dialogo, salvare e chiudere la finestra del codice, tornare al foglio di lavoro e immettere questa formula: =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:

Nota: Nella formula sopra, A2: C11 è l'intervallo di dati che desideri utilizzare, E2 è il valore di ricerca, il numero 3 è il numero di colonna che contiene i valori restituiti.

Vlookup per restituire più valori in una cella con una funzione utile

 Se hai il nostro file Kutools for Excel, Con la sua Combina righe avanzate funzione, puoi unire o combinare rapidamente le righe in base allo stesso valore ed eseguire alcuni calcoli di cui hai bisogno.

Nota:Per applicare questo Combina righe avanzate, in primo luogo, dovresti scaricare il file Kutools for Excele quindi applica la funzione in modo rapido e semplice.

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

1. Seleziona l'intervallo di dati in cui desideri combinare i dati di una colonna in base a un'altra colonna.

2. Clic Kutools > Unisci e dividi > Combina righe avanzate, vedi screenshot:

3. Nel saltò fuori Combina righe avanzate la finestra di dialogo:

  • Fare clic sul nome della colonna chiave da combinare in base a, quindi fare clic su Chiave primaria
  • Quindi fare clic su un'altra colonna di cui si desidera combinare i dati in base alla colonna chiave e fare clic Combinare per scegliere un separatore per separare i dati combinati.

4. Quindi fare clic su OK pulsante e otterrai i seguenti risultati:

Scarica e prova gratuitamente Kutools per Excel ora!


Articoli più relativi:

  • Funzione CERCA.VERT con alcuni esempi di base e avanzati
  • In Excel, la funzione CERCA.VERT è una funzione potente per la maggior parte degli utenti di Excel, che viene utilizzata per cercare un valore nella parte più a sinistra dell'intervallo di dati e restituire un valore corrispondente nella stessa riga da una colonna specificata. Questo tutorial parla di come utilizzare la funzione CERCA.VERT con alcuni esempi di base e avanzati in Excel.
  • Restituisce più valori corrispondenti in base a uno o più criteri
  • Normalmente, cercare un valore specifico e restituire l'elemento corrispondente è facile per la maggior parte di noi utilizzando la funzione CERCA.VERT. Ma hai mai provato a restituire più valori corrispondenti in base a uno o più criteri? In questo articolo, introdurrò alcune formule per risolvere questo compito complesso in Excel.
  • Vlookup e restituisce più valori verticalmente
  • Normalmente, puoi usare la funzione Vlookup per ottenere il primo valore corrispondente, ma, a volte, vuoi restituire tutti i record corrispondenti in base a un criterio specifico. In questo articolo, parlerò di come visualizzare e restituire tutti i valori corrispondenti verticalmente, orizzontalmente o in una singola cella.
  • Vlookup e restituisce più valori dall'elenco a discesa
  • In Excel, come potresti visualizzare e restituire più valori corrispondenti da un elenco a discesa, il che significa che quando scegli un elemento dall'elenco a discesa, tutti i suoi valori relativi vengono visualizzati contemporaneamente. In questo articolo, introdurrò la soluzione passo dopo passo.

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 (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