+ Reply to Thread
Results 1 to 5 of 5

Multiple Look up to return multiple values.

Hybrid View

  1. #1
    Registered User
    Join Date
    11-11-2008
    Location
    Utah
    Posts
    3

    Multiple Look up to return multiple values.

    Hi,
    This is a bit hard to explain, and I am not so sure it can be done, so I attached an example. I would like to compare a couple of ranges namely unit and date, and where those items match, display the control numbers for those matching ranges. I know I can do this with a pivot table (with the date and control number in the row field, and expand the cont numbers), but for a number of reasons I can't use a pivot table for this particular application. Ideally the control numbers would be concatenated in one cell.
    This is a small sample of a rather large spreadsheet, and the units in C1:E1 could change....which is why there are additional units in the data sheet.
    Any help and assistance would be appreciated.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    08-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    573

    Re: Multiple Look up to return multiple values.

    Try this code..
    Sub Find_Cont_Num()
    For i = 3 To Worksheets("Sheet").Range("A65536").End(xlUp).Row
    Ouput = ""
        For Each Cell In Range("DateRange")
            If (Cell.Value = Worksheets("Sheet").Cells(i, 1)) And _
                (Not Range("CurrentUnits").Find(Cell.Offset(0, -3)) Is Nothing) Then
               Output = Output & Cell.Offset(0, -2) & ", "
            End If
        Next Cell
        Worksheets("Sheet").Cells(i, 2) = Output
    Next i
                
    End Sub

  3. #3
    Registered User
    Join Date
    11-11-2008
    Location
    Utah
    Posts
    3

    Re: Multiple Look up to return multiple values.

    Sindhus,
    The code works perfectly, however it also adds the contents from the previous row string. I need only the cont#s that meet the date and unit criteria. For instance, in 8 thru 12 Oct there would be no control numbers, and on 13 Oct there would only be one control number (1041).
    Thanks much for the help.

  4. #4
    Valued Forum Contributor
    Join Date
    08-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    573

    Re: Multiple Look up to return multiple values.

    Oops.. Output is wrongly spelt.

    In the third line of the code, it should be Output=""

  5. #5
    Registered User
    Join Date
    11-11-2008
    Location
    Utah
    Posts
    3

    Re: Multiple Look up to return multiple values.

    Haha, I should have caught that! Thank you so much, this works perfectly!

+ 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