Saltar al contenido principal

¿Cómo visualizar y concatenar múltiples valores correspondientes en Excel?

Como todos sabemos, el Vlookup La función en Excel puede ayudarnos a buscar un valor y devolver los datos correspondientes en otra columna, pero en general, solo puede obtener el primer valor relativo si hay varios datos coincidentes. En este artículo, hablaré sobre cómo buscar y concatenar múltiples valores correspondientes en una sola celda o en una lista vertical.

Vlookup y devuelve múltiples valores coincidentes verticalmente con fórmula

Vlookup y concatenar múltiples valores coincidentes en una celda con la función definida por el usuario

Vlookup y concatenar múltiples valores coincidentes en una celda con Kutools para Excel


Supongamos que tengo el siguiente rango de datos, para obtener todos los valores correspondientes basados ​​en un valor específico verticalmente como se muestra en la siguiente captura de pantalla, puede aplicar una fórmula de matriz.

doc vlookup concatenar 1

1. Ingrese esta fórmula: =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))),"") en una celda en blanco donde desea poner el resultado, por ejemplo, E2, y luego presione Ctrl + Shift + Enter claves juntas para obtener la base del valor relativo en un criterio específico, vea la captura de pantalla:

doc vlookup concatenar 2

Note: En la fórmula anterior:

A1: A16 es el rango de la columna que contiene el valor específico que desea buscar;

D2 indica el valor específico que desea visualizar;

B1: B16 es el rango de columna del que desea devolver los datos correspondientes;

$ 1: $ 16 indica la referencia de filas dentro del rango.

2. Luego seleccione la celda E2 y arrastre el controlador de relleno hacia las celdas hasta que obtenga celdas en blanco, y todos los valores coincidentes se enumeran en la columna como se muestra en la siguiente captura de pantalla:

doc vlookup concatenar 3


En lugar de obtener los valores relativos verticalmente, a veces, desea los valores coincidentes en una celda y concatenarlos con un separador específico. En este caso, la siguiente función definida por el usuario puede hacerle un favor.

1. Mantenga pulsado el botón ALT + F11 teclas para abrir el Microsoft Visual Basic para aplicaciones ventana.

2. Hacer clic recuadro > Móduloy pegue el siguiente código en el Módulo Ventana.

Código de VBA: Vlookup y concatenar múltiples valores coincidentes en una celda

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. Luego guarde y cierre este código, regrese a la hoja de trabajo e ingrese esta fórmula: = cusvlookup (D2, A1: B16,2) en una celda en blanco donde desea poner el resultado y presione Participar clave, todos los valores correspondientes basados ​​en datos específicos se han devuelto en una celda con separador de espacios, vea la captura de pantalla:

doc vlookup concatenar 4

Note: En la fórmula anterior: D2 indica los valores de celda que desea buscar, A1: B16 es el rango de datos que desea obtener los datos, el número 2 es el número de columna desde el que se devolverá el valor coincidente, puede cambiar estas referencias según sus necesidades.


Si tiene Kutools for Excel, Con su Filas combinadas avanzadas característica, puede terminar rápidamente este trabajo con facilidad. Esta función puede ayudarlo a combinar todos los valores coincidentes con delimitadores específicos basados ​​en los mismos datos en otra columna.

Kutools for Excel : con más de 300 prácticos complementos de Excel, prueba gratuita y sin límite en 30 días.

Después de instalar Kutools for Excel, haga lo siguiente:

1. Seleccione el rango de datos del que desea obtener los valores correspondientes en función de los datos específicos.

2. Luego haga clic Kutools > Fusionar y dividir > Filas combinadas avanzadas, ver captura de pantalla:

3. En la Filas combinadas avanzadas cuadro de diálogo, haga clic en el nombre de la columna en la que desea combinar, luego haga clic en Clave primaria botón, ver captura de pantalla:

doc vlookup concatenar 6

4. Luego, haga clic en otro nombre de columna que desee devolver los valores coincidentes y haga clic en Combinar para elegir un separador para separar los valores combinados, vea la captura de pantalla:

doc vlookup concatenar 7

5. Y luego haz clic Ok botón, todos los valores correspondientes basados ​​en los mismos valores se han combinado con un separador específico, ver capturas de pantalla:

doc vlookup concatenar 8 2 doc vlookup concatenar 9

 ¡Descargue y pruebe Kutools para Excel ahora!


Kutools for Excel: con más de 300 prácticos complementos de Excel, prueba gratuita y sin límite en 30 días. ¡Descarga y prueba gratis ahora!

Las mejores herramientas de productividad de oficina

🤖 Asistente de IA de Kutools: Revolucionar el análisis de datos basado en: Ejecución inteligente   |  Generar codigo  |  Crear fórmulas personalizadas  |  Analizar datos y generar gráficos  |  Invocar funciones de Kutools...
Características populares: Buscar, resaltar o identificar duplicados   |  Eliminar filas en blanco   |  Combine columnas o celdas sin perder datos   |   Ronda sin fórmula ...
Super búsqueda: Búsqueda virtual de criterios múltiples    Búsqueda V de valores múltiples  |   VLookup en varias hojas   |   Búsqueda difusa ....
Lista desplegable avanzada: Crear rápidamente una lista desplegable   |  Lista desplegable dependiente   |  Lista desplegable de selección múltiple ....
Administrador de columnas: Agregar un número específico de columnas  |  Mover columnas  |  Toggle Estado de visibilidad de columnas ocultas  |  Comparar rangos y columnas ...
Características destacadas: Enfoque de cuadrícula   |  Vista de diseño   |   Gran barra de fórmulas    Administrador de hojas y libros de trabajo   |  Biblioteca de Recursos (Texto automático)   |  Selector de fechas   |  Combinar hojas de trabajo   |  Cifrar/descifrar celdas    Enviar correos electrónicos por lista   |  Súper filtro   |   Filtro especial (filtro negrita/cursiva/tachado...) ...
Los 15 mejores conjuntos de herramientas12 Texto Herramientas (Añadir texto, Quitar caracteres, ...)   |   50+ Tabla Tipos (Diagrama de Gantt, ...)   |   40+ Práctico Fórmulas (Calcular la edad según el cumpleaños, ...)   |   19 Inserción Herramientas (Insertar código QR, Insertar imagen desde la ruta, ...)   |   12 Conversión Herramientas (Números a palabras, Conversión de Moneda, ...)   |   7 Fusionar y dividir Herramientas (Filas combinadas avanzadas, Células partidas, ...)   |   ... y más

Mejore sus habilidades de Excel con Kutools for Excel y experimente la eficiencia como nunca antes. Kutools for Excel ofrece más de 300 funciones avanzadas para aumentar la productividad y ahorrar tiempo.  Haga clic aquí para obtener la función que más necesita...

Descripción


Office Tab lleva la interfaz con pestañas a Office y hace que su trabajo sea mucho más fácil

  • Habilite la edición y lectura con pestañas en Word, Excel, PowerPoint, Publisher, Access, Visio y Project.
  • Abra y cree varios documentos en nuevas pestañas de la misma ventana, en lugar de en nuevas ventanas.
  • ¡Aumenta su productividad en un 50% y reduce cientos de clics del mouse todos los días!
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