+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: Lookup to find and output multiple values in different worksheet

  1. #1
    Registered User
    Join Date
    12-29-2009
    Location
    Milwaukee, US
    MS-Off Ver
    Excel 2007
    Posts
    25

    Lookup to find and output multiple values in different worksheet

    Hi,
    I’m trying to use Lookup to generate a traceability matrix. For each requirement in worksheet A, I want to input what all test cases are present in Worksheet 2. By using the lookup, it just returns the first occurrence and not the others. Attached is that example sheet. Any help would be highly appreciated.
    Thanks
    Attached Files Attached Files
    Last edited by harsh2209; 03-08-2010 at 05:22 PM.

  2. #2
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: Lookup to find and output multiple values in different worksheet

    Add this udf to your VB Editor (ALT+F11, Insert|Module)

    Function aconcat(a As Variant, Optional sep As String = "") As String
    ' Harlan Grove, Mar 2002
    Dim y As Variant
    
    If TypeOf a Is Range Then
    For Each y In a.Cells
    aconcat = aconcat & y.Value & sep
    Next y
    ElseIf IsArray(a) Then
    For Each y In a
    aconcat = aconcat & y & sep
    Next y
    Else
    aconcat = aconcat & a & sep
    End If
    
    aconcat = Left(aconcat, Len(aconcat) - Len(sep))
    End Function
    Then use formula in E2:

    =SUBSTITUTE(TRIM(aconcat(IF('Test Cases'!$A$2:$A$34=B2,'Test Cases'!$B$2:$B$34,"")," "))," ",",")

    and confirm it with CTRL+SHIFT+ENTER not just ENTER and copy it down
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  3. #3
    Registered User
    Join Date
    12-29-2009
    Location
    Milwaukee, US
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Lookup to find and output multiple values in different worksheet

    Thanks NVBC!

    However, I'm trying to understand why I'm getting all test case numbers which do not have any requirement mapped against some requirements..Could you please see what happens if some of the test cases do not have a requirement id?

  4. #4
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: Lookup to find and output multiple values in different worksheet

    Are you confirming the formula with CTRL+SHIFT+ENTER so that you get { } brackets around the formula?
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  5. #5
    Registered User
    Join Date
    12-29-2009
    Location
    Milwaukee, US
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Lookup to find and output multiple values in different worksheet

    Thanks Again, Yes I'm doing it. It works very well.

    One more thing. So, is it also possible that the logic picks up more then one requirements separated by comma from one cell.
    Please see the example in the attached file - 'Example2.xlsm'
    Attached Files Attached Files
    Last edited by harsh2209; 03-03-2010 at 03:25 PM.

  6. #6
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: Lookup to find and output multiple values in different worksheet

    Did you attach another file?
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  7. #7
    Registered User
    Join Date
    12-29-2009
    Location
    Milwaukee, US
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Lookup to find and output multiple values in different worksheet

    Sorry, I did now..

  8. #8
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: Lookup to find and output multiple values in different worksheet

    Try:

    =SUBSTITUTE(TRIM(aconcat(IF(ISNUMBER(SEARCH(B2,'Test Cases'!$A$2:$A$34)),'Test Cases'!$B$2:$B$34,"")," "))," ",",")

    confirmed with CTRL+SHIFT+ENTER and copied down.
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  9. #9
    Registered User
    Join Date
    12-29-2009
    Location
    Milwaukee, US
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Lookup to find and output multiple values in different worksheet

    Again, works like a charm!

    Thanks a lot!

  10. #10
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: Lookup to find and output multiple values in different worksheet

    Great!

    Can you remember to please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  11. #11
    Registered User
    Join Date
    12-29-2009
    Location
    Milwaukee, US
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Lookup to find and output multiple values in different worksheet

    Sure! but, what if I have some more questions..do I open a new thread?

  12. #12
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: Lookup to find and output multiple values in different worksheet

    If it is directly related to this actual question, then no Mark it back to No Prefix and then ask..

    ... if is not directly related, then start a new thread.. you can add link to here if you feel it necessary...
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  13. #13
    Registered User
    Join Date
    12-29-2009
    Location
    Milwaukee, US
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Lookup to find and output multiple values in different worksheet

    Hi NBVC,

    The solution you proved work well. Here is one discrepancy that I have come across.

    The formula & macro cannot differentiate between requirement '6.2.0' and '16.2.0'. So, the test cases mapped to 16.2.0, 16.2.1 are also getting automatically mapped to 6.2.0 and 6.2.1...

    Attached example2.xlsm with the scenario..

    Any thought/ way out..
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    12-29-2009
    Location
    Milwaukee, US
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Lookup to find and output multiple values in different worksheet

    The formula & macro cannot differentiate between requirement '6.2.0' and '16.2.0'. So, the test cases mapped to 16.2.0, 16.2.1 are also getting automatically mapped to 6.2.0 and 6.2.1...

    Attached example2.xlsm with the scenario..

    Any thought/ way out..

  15. #15
    Registered User
    Join Date
    12-29-2009
    Location
    Milwaukee, US
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Lookup to find and output multiple values in different worksheet

    Could you please help...

+ 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.2.0