+ Reply to Thread
Results 1 to 2 of 2

Multiple Lookup Criteria and Concatenate Multiple Results

Hybrid View

Elwood07 Multiple Lookup Criteria and... 07-23-2012, 10:23 PM
Elwood07 Re: Multiple Lookup Criteria... 07-26-2012, 10:27 AM
  1. #1
    Registered User
    Join Date
    09-16-2011
    Location
    orlando
    MS-Off Ver
    Excel 2003
    Posts
    5

    Multiple Lookup Criteria and Concatenate Multiple Results

    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!
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    09-16-2011
    Location
    orlando
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Multiple Lookup Criteria and Concatenate Multiple Results

    Any chance anyone can assist?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1