Lookup Table in one sheet and Data in another

Teleporpoise

New Member
Joined
May 23, 2019
Messages
31
Hi All,

I have a data in one sheet in the workbook that in column A, it keeps track of individuals names, in B, the dates that they came into work, and in C, which shift they worked (work is divided in 3 shifts M, A, or E). I want to create another sheet, where one person's name can be typed, and I output the dates and shifts they work in. I've put in this code in a module on a test set of data (only columns A and B):

VBA Code:
Function MultiLookup(Lookup_value As Range, Lookup_range, return_range, delimiter)
    
    lrow = ActiveSheet.UsedRange.Rows.Count
    Count = 1
    For Each cell In Lookup_range
        If cell.Row() > lrow Then Exit For
        
        If cell = Lookup_value Then
            addval = return_range(Count)
            If MultiLookup = "" Then
                MultiLookup = addval
            Else
                MultiLookup = MultiLookup & delimiter & addval
            End If
        End If
        Count = Count + 1
    Next cell
    
End Function

And in a cell I input this code:
Excel Formula:
=MultiLOOKUP(A1,A:A,B:B,",")

This does work, but it returns all the values with a comma in them in one cell. I ideally want multiple cells for each entry.

Any advice or reccomendations?
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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