Direkt zum Inhalt

So führen Sie eine Vlookup-Suche durch, um mehrere Werte in einer Zelle zurückzugeben Excel?

Normalerweise in ExcelWenn Sie die VLOOKUP-Funktion verwenden und mehrere Werte vorhanden sind, die den Kriterien entsprechen, können Sie einfach den ersten abrufen. Aber manchmal möchten Sie alle entsprechenden Werte, die die Kriterien erfüllen, in einer Zelle zurückgeben, wie im folgenden Screenshot gezeigt. Wie können Sie das lösen?

Vlookup, um mit der TEXTJOIN-Funktion mehrere Werte in eine Zelle zurückzugeben (Excel 2019 und Office 365)

Vlookup, um mehrere Werte mit einer benutzerdefinierten Funktion in eine Zelle zurückzugeben

Vlookup, um mehrere Werte mit einer nützlichen Funktion in eine Zelle zurückzugeben


Vlookup, um mit der TEXTJOIN-Funktion mehrere Werte in eine Zelle zurückzugeben (Excel 2019 und Office 365)

Wenn Sie die höhere Version von haben Excel sowie Excel 2019 und Office 365 gibt es eine neue Funktion - TEXTVERBINDENMit dieser leistungsstarken Funktion können Sie schnell alle übereinstimmenden Werte in einer Zelle anzeigen und zurückgeben.

Vlookup, um alle übereinstimmenden Werte in einer Zelle zurückzugeben

Bitte wenden Sie die folgende Formel in eine leere Zelle an, in die Sie das Ergebnis einfügen möchten, und drücken Sie dann Strg + Umschalt + Enter Geben Sie die Tasten zusammen, um das erste Ergebnis zu erhalten, und ziehen Sie dann den Füllpunkt nach unten in die Zelle, in der Sie diese Formel verwenden möchten. Sie erhalten alle entsprechenden Werte wie im folgenden Screenshot gezeigt:

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

Hinweis: In der obigen Formel A2: A11 Ist der Suchbereich enthält die Suchdaten, E2 ist der Suchwert, C2: C11 ist der Datenbereich, aus dem Sie die übereinstimmenden Werte zurückgeben möchten. ","ist das Trennzeichen zum Trennen der mehreren Datensätze.

Vlookup, um alle übereinstimmenden Werte ohne Duplikate in einer Zelle zurückzugeben

Wenn Sie alle übereinstimmenden Werte basierend auf den Suchdaten ohne Duplikate zurückgeben möchten, kann die folgende Formel hilfreich sein.

Bitte kopieren Sie die folgende Formel und fügen Sie sie in eine leere Zelle ein. Drücken Sie dann Strg + Umschalt + Enter Geben Sie die Tasten zusammen, um das erste Ergebnis zu erhalten, und kopieren Sie diese Formel, um andere Zellen zu füllen. Sie erhalten dann alle entsprechenden Werte ohne die doppelten Werte, wie im folgenden Screenshot gezeigt:

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

Hinweis: In der obigen Formel A2: A11 Ist der Suchbereich enthält die Suchdaten, E2 ist der Suchwert, C2: C11 ist der Datenbereich, aus dem Sie die übereinstimmenden Werte zurückgeben möchten. ","ist das Trennzeichen zum Trennen der mehreren Datensätze.

Vlookup, um mehrere Werte mit einer benutzerdefinierten Funktion in eine Zelle zurückzugeben

Die obige TEXTJOIN-Funktion ist nur verfügbar für Excel 2019 und Office 365, falls Sie andere niedrigere Versionen haben Excel Versionen verwenden, sollten Sie einige Codes zum Abschließen dieser Aufgabe verwenden.

Vlookup, um alle übereinstimmenden Werte in einer Zelle zurückzugeben

1. Halten Sie die Taste gedrückt ALT + F11 Tasten, und es öffnet die Microsoft Visual Basic für Applikationen Fenster.

2. Klicken Sie Insert > Modulund fügen Sie den folgenden Code in das Feld ein Modulfenster.

VBA-Code: Vlookup, um mehrere Werte in eine Zelle zurückzugeben

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. Speichern und schließen Sie diesen Code, kehren Sie zum Arbeitsblatt zurück und geben Sie die folgende Formel ein: =CONCATENATEIF($A$2:$A$11, E2, $C$2:$C$11, ", ") in eine bestimmte leere Zelle, in der Sie das Ergebnis platzieren möchten, und ziehen Sie dann den Füllpunkt nach unten, um alle entsprechenden Werte in einer gewünschten Zelle zu erhalten (siehe Abbildung):

Hinweis: In der obigen Formel A2: A11 Ist der Suchbereich enthält die Suchdaten, E2 ist der Suchwert, C2: C11 ist der Datenbereich, aus dem Sie die übereinstimmenden Werte zurückgeben möchten. ","ist das Trennzeichen zum Trennen der mehreren Datensätze.

Vlookup, um alle übereinstimmenden Werte ohne Duplikate in einer Zelle zurückzugeben

Um die Duplikate in den zurückgegebenen übereinstimmenden Werten zu ignorieren, verwenden Sie bitte den folgenden Code.

1. Halten Sie die Taste gedrückt Alt + F11 Schlüssel zum Öffnen der Microsoft Visual Basic für Applikationen Fenster.

2. Klicken Sie Insert > Modulund fügen Sie den folgenden Code in das Feld ein Modulfenster.

VBA-Code: Suchen Sie und geben Sie mehrere eindeutige übereinstimmende Werte in einer Zelle zurück

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. Klicken Sie nach dem Einfügen des Codes auf Tools > Referenzen im geöffneten Microsoft Visual Basic für Applikationen Fenster, und dann in der herausgesprungen Referenzen - VBAProject Dialogfeld überprüfen Microsoft Scripting-Laufzeit Option in der Verfügbare Referenzen Listenfeld, siehe Screenshots:

4. Dann klick OK Um das Dialogfeld zu schließen, speichern und schließen Sie das Codefenster, kehren Sie zum Arbeitsblatt zurück und geben Sie die folgende Formel ein: =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:

Hinweis: In der obigen Formel A2: C11 ist der Datenbereich, den Sie verwenden möchten, E2 ist der Suchwert, die Zahl 3 ist die Spaltennummer, die die zurückgegebenen Werte enthält.

Vlookup, um mehrere Werte mit einer nützlichen Funktion in eine Zelle zurückzugeben

 Wenn Sie unsere haben Kutools for ExcelMit seinen Erweiterte Zeilen kombinieren Mit dieser Funktion können Sie die Zeilen basierend auf demselben Wert schnell zusammenführen oder kombinieren und nach Bedarf einige Berechnungen durchführen.

Hinweis:Um dies anzuwenden Erweiterte Zeilen kombinierenZunächst sollten Sie die herunterladen Kutools for Excelund wenden Sie die Funktion dann schnell und einfach an.

Nach der Installation Kutools for ExcelBitte gehen Sie wie folgt vor:

1. Wählen Sie den Datenbereich aus, in dem Sie eine Spaltendaten basierend auf einer anderen Spalte kombinieren möchten.

2. Klicken Sie Kutools > Zusammenführen & Teilen > Erweiterte Zeilen kombinieren, siehe Screenshot:

3. In der herausgesprungen Erweiterte Zeilen kombinieren Dialogbox:

  • Klicken Sie auf den Namen der Schlüsselspalte, auf der basierend kombiniert werden soll, und klicken Sie dann auf Primärschlüssel
  • Klicken Sie dann auf eine andere Spalte, deren Daten Sie basierend auf der Schlüsselspalte kombinieren möchten, und klicken Sie auf Kombinieren ein Trennzeichen zum Trennen der kombinierten Daten auswählen.

4. Dann klick OK Klicken Sie auf die Schaltfläche, und Sie erhalten die folgenden Ergebnisse:

Download und kostenlose Testversion Kutools for Excel Jetzt !


Weitere relative Artikel:

  • VLOOKUP-Funktion mit einigen grundlegenden und erweiterten Beispielen
  • In Excel, die SVERWEIS-Funktion ist für die meisten eine leistungsstarke Funktion Excel Benutzer, die verwendet werden, um nach einem Wert ganz links im Datenbereich zu suchen und einen passenden Wert in derselben Zeile aus einer von Ihnen angegebenen Spalte zurückzugeben. In diesem Tutorial geht es um die Verwendung der SVERWEIS-Funktion anhand einiger grundlegender und fortgeschrittener Beispiele Excel.
  • Gibt mehrere übereinstimmende Werte basierend auf einem oder mehreren Kriterien zurück
  • Normalerweise ist es für die meisten von uns einfach, mit der VLOOKUP-Funktion nach einem bestimmten Wert zu suchen und das entsprechende Element zurückzugeben. Aber haben Sie schon einmal versucht, mehrere übereinstimmende Werte basierend auf einem oder mehreren Kriterien zurückzugeben? In diesem Artikel werde ich einige Formeln zur Lösung dieser komplexen Aufgabe vorstellen Excel.
  • Mehrere Werte vertikal anzeigen und zurückgeben
  • Normalerweise können Sie die Vlookup-Funktion verwenden, um den ersten entsprechenden Wert abzurufen. Manchmal möchten Sie jedoch alle übereinstimmenden Datensätze basierend auf einem bestimmten Kriterium zurückgeben. In diesem Artikel werde ich darüber sprechen, wie alle übereinstimmenden Werte vertikal, horizontal oder in einer einzelnen Zelle angezeigt und zurückgegeben werden.
  • Anzeigen und Zurückgeben mehrerer Werte aus der Dropdown-Liste
  • In Excel, wie könnten Sie mehrere entsprechende Werte aus einer Dropdown-Liste nachschlagen und zurückgeben? Wenn Sie also ein Element aus der Dropdown-Liste auswählen, werden alle relativen Werte gleichzeitig angezeigt. In diesem Artikel werde ich die Lösung Schritt für Schritt vorstellen.

Beste Office-Produktivitätstools

Bringen Sie Ihre Tabellen auf den neuesten Stand: Erleben Sie Effizienz wie nie zuvor mit Kutools for Excel

Beliebte Funktionen: Duplikate suchen/hervorheben/identifizieren   |  Leere Zeilen löschen   |  Kombinieren Sie Spalten oder Zellen, ohne Daten zu verlieren   |   Runde ohne Formel ...
Super-Lookup: VLookup mit mehreren Kriterien    VLookup mit mehreren Werten  |   VLookup über mehrere Blätter hinweg   |   Unscharfe Suche ....
Erweiterte Dropdown-Liste: Erstellen Sie schnell eine Dropdown-Liste   |  Abhängige Dropdown-Liste   |  Mehrfachauswahl Dropdown-Liste ....
Spaltenmanager: Fügen Sie eine bestimmte Anzahl von Spalten hinzu     Spalten verschieben   |   Spalten einblenden   |   Spalten vergleichen mit Wählen Sie Gleiche und Unterschiedliche Zellen ...
Ausgewählte Funktionen: Rasterfokus   |  Designansicht   |   Große Formelleiste    Arbeitsmappen- und Blattmanager   |  Ressourcen (Autotext)   |  Datumsauswahl   |  Arbeitsblätter kombinieren   |  Zellen verschlüsseln/entschlüsseln    Senden Sie E-Mails nach Liste   |  Superfilter   |   Spezialfilter (Filter fett/kursiv/durchgestrichen...) ...
Top 15 Toolset12 Text Tools (Text hinzufügen, Zeichen entfernen, ...)   |   50+ Chart Typen (Gantt-Diagramm, ...)   |   40+ Praktisch Formeln (Berechnen Sie das Alter basierend auf dem Geburtstag, ...)   |   19 Einfügen Tools (QR-Code einfügen, Bild aus Pfad einfügen, ...)   |   12 Umwandlung (Conversion) Tools (Zahlen zu Words, Currency Conversion, ...)   |   7 Zusammenführen & Teilen Tools (Erweiterte Zeilen kombinieren, Zellen teilen, ...)   |   Viel mehr...

Kutools for Excel verfügt über über 300 Funktionen, Stellen Sie sicher, dass das, was Sie brauchen, nur einen Klick entfernt ist ...

Unterstützt Office/Excel 2007–2021 und neuer, einschließlich 365 | Verfügbar in 44 Sprachen | Genießen Sie eine 30-tägige kostenlose Testversion mit vollem Funktionsumfang.

kte tab 201905


Office Tab Bringt eine Tab-Oberfläche in Office und erleichtert Ihnen die Arbeit erheblich

  • Aktivieren Sie das Bearbeiten und Einlesen mit Registerkarten Word, Excel, Power Point, Publisher, Access, Visio und Project.
  • Öffnen und erstellen Sie mehrere Dokumente in neuen Registerkarten desselben Fensters und nicht in neuen Fenstern.
  • Steigert Ihre Produktivität um 50 % und reduziert jeden Tag Hunderte von Mausklicks für Sie!
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.
This comment was minimized by the moderator on the site
Put comma between each response: =SUBSTITUTE(TRIM(myvlookup(E6,$A$2:$C$15,2))," ",", ")
This comment was minimized by the moderator on the site
Unfortunately it does not work for me =myvlookup(E6,$A$2:$C$15,2) as the result is #NAME?
This comment was minimized by the moderator on the site
Did you get this figured out? I am having the same problem.
This comment was minimized by the moderator on the site
having the same problem :(
This comment was minimized by the moderator on the site
Thank you. I just modified so that it will replace the comma at the start and replace the last comma with "And".

(Working with states)

Function MYVLOOKUP(pValue As String, pWorkRng As Range, pIndex As Long)

Dim rng As Range
Dim xResult, States As String
Dim Pos As Long
xResult = ""
For Each rng In pWorkRng
If rng = pValue Then
xResult = xResult & ", " & rng.Offset(0, pIndex - 1)
End If
Next
States = Right(xResult, Len(xResult) - 2)
Pos = InStrRev(States, ",")

If Pos > 1 Then
States = Mid(States, 1, Pos - 1) & Replace(States, ",", " AND", Pos)

End If

MYVLOOKUP = States
End Function
This comment was minimized by the moderator on the site
do we have the code to work it from last to first. like we have multiple values in columnB and we want them in row with column A remain same.
This comment was minimized by the moderator on the site
For some reason this macro is extremely slow for me, every time I click anywhere it takes about 5-10 minutes to calculate.
This comment was minimized by the moderator on the site
Tthat's what I wanted! Thank you very much XD
This comment was minimized by the moderator on the site
This is amazing, thank you!
This comment was minimized by the moderator on the site
Great function, however chunking through 100,000 records proves a bit much for my poor laptop, will need to let it run overnight!
This comment was minimized by the moderator on the site
Is there a way of amending the result so instead of showing 1000 1000 -1000 it would show for example 1,000/1,000/(1,000) ?
This comment was minimized by the moderator on the site
Great macro, useful. But need to know can it be modified to check 2 criteria & does anyone found anyway to make wildcards work on it. Any help?
This comment was minimized by the moderator on the site
No matter what I do, I always get #value! returned instead of a result. vlookup works just fine, so the data works. Already followed the process of enabling macros. I even combined everything into a single sheet. Any ideas??
This comment was minimized by the moderator on the site
This worked perfectly, but it did take me some time to get the Function work properly within my 20 tab, 50k+ line spreadsheet. Now the BIG question is how to take that delimited string and then use each entry as an Index/Match (not married to Index/Match, but it seems faster) lookup value in another dataset, returning the SUM value of all returns into one cell. My scenario is that I have a Single Order that has multiple invoices. Your MYVLOOKUP Function works superbly to report back all of the invoices in one cell. What I want to do now is to take each concatenated return with the reported cell, spin through that array and total the amounts of payment of each invoice back into the formula cell. I appreciate any help that you can offer on this and thanks for the MYVLOOKUP Function!
This comment was minimized by the moderator on the site
To get unique record, you may use below: (modified by refer other user code) Function MYVLOOKUP(pValue As String, pWorkRng As Range, pIndex As Long) 'Update 20150310 'Updated 6/9/16 Jay Coltrain 'Dim rng As Range Dim xResult As String xResult = "" Dim Rows As Long, i As Long Rows = pWorkRng.Rows.Count For i = 1 To Rows If pWorkRng.Cells(i, 1).Value = pValue Then xResult = xResult & "," & pWorkRng.Cells(i, 1).Offset(0, pIndex - 1) End If Next i Dim varSection As Variant Dim sTemp As String Dim sDelimiter As String sDelimiter = "," For Each varSection In Split(xResult, sDelimiter) If InStr(1, sDelimiter & sTemp & sDelimiter, sDelimiter & varSection & sDelimiter, vbTextCompare) = 0 Then sTemp = sTemp & sDelimiter & varSection End If Next varSection MYVLOOKUP = Mid(sTemp, Len(sDelimiter) + 1) End Function
This comment was minimized by the moderator on the site
Heads-up. I figured out how to get any separator in that output. Its rudimentary. But I figured it out. xResult = xResult & "///" & rng.Offset(0, pIndex - 1) The last and most wished for thing though is enabling it to work with wildcards in the search criteria. Thank you again for this beautiful and brilliant solution. Extremely helpful. Now just want to get get the macro to run and be installed in my excel perminantly no matter what I'm doing so I can use it when I need to. And wildcards! Thank you so much. Wildcards are all that are left to do.
This comment was minimized by the moderator on the site
Hi, It works well. What I would like to do is adapt the code to seperate thee value results with "///" or any other marker (for technical reasons, I don't want just a single character seperator). Also, I noticed that this formula doesnt work with a wild card. I know i am asking too much, but it doesnt as vlookup can work when i search for =myvlookup("*"&E6&"*",$A$2:$C$15,2) which it would do/could do. Any assistance?
This comment was minimized by the moderator on the site
Return nothing! after applying MYLOOKUP giving no result but blank.
This comment was minimized by the moderator on the site
Notify me of follow-up comments
This comment was minimized by the moderator on the site
This works great, but I still need help with the command function to remove duplicates from the results.
This comment was minimized by the moderator on the site
This works great, but I need help with the command to remove duplicates from the results. Seriously though, Great work.
This comment was minimized by the moderator on the site
This is exactly what I was looking for and did not think of just making my own UDF. However it will not function exactly like VLOOKUP. If the string you are looking for is not only in the first column then it could give you data outside the original range passed. Name Number Other name Column not in range passed Jay 1 Jay 1 Jay 2 Jay 2 Chris 3 Chris 3 Jorge 4 Jorge 4 Jay 5 Jay 5 Jorge 6 Jorge 6 If the above table were cells A1:D7 if you passed only A1:C7 your "MYVLOOKUP" function returns 1 1 2 2 5 5 when you would expect it to return 1 2 5. The changes below fix the issue: Function MYVLOOKUP(pValue As String, pWorkRng As Range, pIndex As Long) 'Update 20150310 'Updated 6/9/16 Jay Coltrain 'Dim rng As Range Dim xResult As String xResult = "" Dim Rows As Long, i As Long Rows = pWorkRng.Rows.Count For i = 1 To Rows If pWorkRng.Cells(i, 1).Value = pValue Then xResult = xResult & " " & pWorkRng.Cells(i, 1).Offset(0, pIndex - 1) End If Next i 'For Each rng In pWorkRng ' If rng = pValue Then ' xResult = xResult & " " & rng.Offset(0, pIndex - 1) ' End If 'Next MYVLOOKUP = xResult End Function
This comment was minimized by the moderator on the site
Thank you for the VBA-code. I got exactly what I want! I modified only the code " rng.Offset(0, pIndex - 1) " to " rng.Offset(0, pIndex - 2) " . So is MYVLOOKUP able to search from Right to Left.
This comment was minimized by the moderator on the site
Hi, i am really impressed with the work and its so easy to create one to use this function. however i need further support. My ? is that how can i select a number from a cell with multiple cell in my vlookup array. i.e. If cell A1 = 100, A2 = 350, A3 = 69 C1 = 100; 1222; 12133 C2 = 69; 222 D1 = Apple D2 = banana So how can select 100 from my table array column C to derive correspondent D1 = apple Please note that i have 7 digit numbers in my lookup value and table array which is separated by a ";". I would really appreciate if you can solve this and help me in saving a lot time.
This comment was minimized by the moderator on the site
Awesome work.. Got exactly what I want !!! Love it !!
This comment was minimized by the moderator on the site
Thank you for sharing the above code. I've been using this for several months now but today it doesn't seem to work. I'm getting blank cells instead of the usual error when there is data to be returned. Any thoughts?
This comment was minimized by the moderator on the site
Thanks for the VBA code above. Can you tell me how to make the results enter onto a new line in the cell, ie like Alt-Enter 300 400 1000 1300
This comment was minimized by the moderator on the site
How would I adjust this formula to separate each returned value but ", " as well as only return unique values?
This comment was minimized by the moderator on the site
Thanks for the code!!

As for wildcards, a way around is using INSTR

You can replace the [ If rng = pValue Then ] with [ InStr(1, rng.Value, pValue) Then ] and if you don't want it to be case sensitive then use [ InStr(1, rng.Value, pValue, vbTextCompare) Then ]
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations