Vlookup multiple values for multiple results

Whatri

New Member
Joined
Nov 23, 2018
Messages
2
Hi everyone,

I have a specific issue i cannot find my way around it..
In cell A1 i have numbers:
357 359 431 452 576 589

In the other sheet i have numbers and names in 2 columns, numbers in A, names in B
351 353 355 357 mario
431 433 435 437 ivan
100 102 104 106 paul

Which formula can i use to search through every number on my first sheet, and to retrieve multiple names with the matching numbers from other sheet?
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Welcome to the board.

This can be done with native Excel formulas, but they'd be long, complicated, and require multiple help columns. You'd probably be better off with a UDF (User-Defined Function). If you want to try that:

Open a copy of your workbook. Press Alt-F11 to open the VBA editor. From the menu, click Insert > Module. In the sheet that opens, paste this code:

Code:
Public Function GetNames(ByVal Src As Range, Tbl As Range) As String
Dim Nums As Variant, MyTab As Variant, i As Long, j As Long

    GetNames = ""
    Nums = Split(Src)
    MyTab = Tbl.Value
    For i = 0 To UBound(Nums)
        For j = 1 To UBound(MyTab)
            If InStr(" " & MyTab(j, 1) & " ", " " & Nums(i) & " ") > 0 Then
                GetNames = GetNames & ", " & MyTab(j, 2)
            End If
        Next j
    Next i
    GetNames = Mid(GetNames, 3)
End Function
Press Alt-Q to close the VBA editor. In B1 of Sheet1, enter this formula:

=GetNames(A1,Sheet2!$A$1:$B$10)

Change the table range as needed. Drag down the column if needed. Let us know if this works for you.
 
Upvote 0
how about PowerQuery

Column1Column1Column2Column1Column2
357 359 431 452 576 589 106351 353 355 357mario357mario
431 433 435 437ivan431ivan
100 102 104 106paul106paul

example excel file

after change any value use Ctrl+Shift+F5
 
Upvote 0

Forum statistics

Threads
1,215,471
Messages
6,125,002
Members
449,202
Latest member
Pertotal

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top