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):
And in a cell I input this code:
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?
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?