Hello,
I have 3 columns of data, "room name" (F), "event date" (G) and "event start time/type" (H)
I am rearranging the data (sort of like a pivot table) in a different sheet that will list unique Room Names in column A with header in cell A6 and Event Dates across row 6. I need a UDF that, given the Room Name and Event Date, will return all matching values for Event Start Time/Type to fill in a grid, with chr(10) separating the values. A pivot table, at best, will only count the number of events that are taking place in a specific room on a specific date instead of showing what they actually are. The point of this project is to convert an automated report into a format requested by our clients, so changing the layout really isn't an option.
So far, I've been able to find a UDF and corresponding formula that will return a value based on multiple criteria, and I've been able to find a UDF and formula that will concatenate all results from a lookup with a single criteria, but I cannot find anything that will do both. Every time this table is created, there will be a different number of date ranges being queried, and a different number of room names listed. I'd rather avoid hidden columns, and I'll probably add a macro that will paste the formula into cell B7, and copy it over to the last date and down to the last row room names
This is the Macro that I found for concatenating results http://www.get-digital-help.com/2010...into-one-cell/
Function Lookup_concat(Search_string As Range, _
Search_in_col As Range, Return_val_col As Range)
Dim i As Long
Dim result As String
For i = 1 To Search_in_col.Count
If Search_in_col.Cells(i, 1) = Search_string Then
result = result & Return_val_col.Cells(i, 1).Value & Chr(10)
End If
Next
result = Left(result, Len(result) - 1)
Lookup_concat = Trim(result)
End Function
and this is the code with the multiple lookups (http://www.excelguide.eu/index.php
Public Function MLOOKUP(GetFromRange As Range, ParamArray Condition() As Variant) As String
Dim vItem As Variant
Dim rngCell As Variant
Dim lItem As Long
Dim lRange As Long
Dim varArray(99) As Variant
Dim lRngCount As Long
Dim lItemCount As Long
Dim x As Long
Dim y As Variant
Dim z As Long
Dim vCell As Variant
lItem = UBound(Condition()) + 1
z = 0
For Each vItem In Condition
For Each rngCell In vItem
lRange = lRange + 1
If CBool(rngCell) = True Then
y = 1
Else
y = 0
End If
sPrint = sPrint & y
Next rngCell
varArray(z) = sPrint
sPrint = ""
z = z + 1
Next vItem
lRange = (lRange / lItem) - 1
x = 1
For lRngCount = 0 To lRange
For lItemCount = 0 To (lItem - 1)
x = Mid(varArray(lItemCount), lRngCount + 1, 1) * x
Next lItemCount
If x = 1 Then
MLOOKUP = GetFromRange.Rows(lRngCount + 1)
Exit Function
End If
x = 1
Next lRngCount
End Function
I have no idea how to adapt them to work together.
I've attached a sample to help better visualize how it's supposed to look.
Any help will be so greatly appreciated!
Thanks so much!
Bookmarks