+ Reply to Thread
Results 1 to 2 of 2

Search list and return multiple values

Hybrid View

  1. #1
    Registered User
    Join Date
    06-21-2012
    Location
    Standerton, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    4

    Search list and return multiple values

    Hi Guys/Gals,

    I have the following problem:

    On Sheet1("Calculation Sheet") I have a Cell("A3") with a dropdown list of species names and a Cell("B3") which returns the occurence code(QDS) of the selected species in A3. On Sheet3("Records") I have occurence records of the species in the following format with a few examples:
    Column A: Species
    Naja mossambicca
    Naja mossambicca
    Naja mossambicca
    Column B: QDS
    3222AB
    3116CA
    2328DD

    Now, if I choose a name in the dropdown list(Sheet1:A3), I need B3 and downwards(as multiple occurences are common) to return the QDS codes.

    At the moment I am using the following in B3:
    =IF(ISERROR(INDEX(Records!$A$2:$B$33202,SMALL(IF(Records!$A$2:$B$33202=$A$3,ROW(Records!$A$2:$B$33202)),ROW(1:1)),2)),"",INDEX(Records!$A$2:$B$33202,SMALL(IF(Records!$A$2:$B$33202=$A$3,ROW(Records!$A$2:$B$33202)),ROW(1:1)),2)

    Firstly, the formula above seems to always omit one search result. Secondly, it takes quite a while(about 30 sec) to display the results, as there are about 33,000 records to process.

    I would like to write a piece of code that could loop through Records:Column A and match all rows with Calculation Sheet:A3, then copy the values in Records:Column B, which corresponds to the matches, to Calculation Sheet:B3 and downwards.

    Some help would be greatly appreciated.

    Cheers for now...

    MarVil

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Search list and return multiple values

    1) You will get back your missing value if you change all the ranges in the formula to start on row 1 instead of row 2. Trust me.

    2) You can eliminate the array formula if you add a "helper" column to the records to INDEX the current value you're displaying, then a Simple INDEX/MATCH can bring over all the matching rows.

    3) To write a code (which I would certainly do in this scenario), I'd need a sample workbook dumbed down to about 100 rows of Records and a CalCulation sheet displaying an example of the results you'd want, be sure to point out the INPUT cell where you will make your selection each time, if it's not patently obvious.

    Click GO ADVANCED and use the paperclip icon to post up a copy of your workbook.


    I can show you the formula technique, too, very robust and no VBA needed, though the sheet will get a little larger, no biggie.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ 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