+ Reply to Thread
Results 1 to 4 of 4

looking up the values in two cells to retrieve the data that applies to both.

  1. #1
    Registered User
    Join Date
    04-26-2009
    Location
    Wisconsin, US
    MS-Off Ver
    Excel 2003
    Posts
    7

    looking up the values in two cells to retrieve the data that applies to both.

    Sorry the title doesn't explain what I am trying to do very well... I want to be able to choose a drug type in one column and the route of administration in the next column and then have the dose information for that drug given in that route displayed across the next few cells in the same row. I have attached a simplified demo spreadsheet.

    Originally I was using a vlookup command and had both the drug and the route in the same cell, however, I need the route in a separate cell for other use on the spreadsheet.

    Also, I was hoping that by using this method I would be able to avoid a mile long drop down menu due to each drug being listed 3 - 5 times (for each route). However, the way I have it set up now the list is just as long, there are just blank spaces. Is there any way to get rid of the spaces in the drop down menu?

    Thanx in advance for your help!!

    demo.xls

    ~Dave

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

    Re: looking up the values in two cells to retrieve the data that applies to both.

    In D5, try:

    =IF($C5="","",VLOOKUP($C5,INDEX($C$21:$C$32,MATCH($B5,$B$21:$B$32,0)):$F$32,COLUMNS($C$1:D$1),0))

    copied across and down the table
    Where there is a will there are many ways.

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

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

  3. #3
    Registered User
    Join Date
    04-26-2009
    Location
    Wisconsin, US
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: looking up the values in two cells to retrieve the data that applies to both.

    This worked great! However, the way it is setup now I will have to have a row for each route even if it is not available because if there is not a row for it, it will find the next time that route is listed. for example... if the following is my "drug book"

    ibuprofen IM 5
    SQ 6
    PO 7
    tylenol IM 8
    IV 9

    and I enter

    ibuprofen, IV

    not knowing that there is not an IV form of ibuprofen

    it will return

    9

    because that is the data associated with the next "IV" found in the list even though it is not truely associated with ibuprofen.

    Is there a way to ensure that the 2nd column choice is truely associated with the 1st column choice?
    If not I can simply enter a row for each route and leave it blank or enter a warning in the "drug book".

    Any ideas on the second question I had in my original post?

    Thanx again!!
    ~Dave

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

    Re: looking up the values in two cells to retrieve the data that applies to both.

    Then the best thing would be do fill in all the cells in Column B of the lookup table so you can do a double match, or you can add a formula in column A at A21 to get the data using formula: =LOOKUP(REPT("z",255),B$21:B21) copied down

    Then in D5 you can use:

    =SUMPRODUCT(D$21:D$32,--($A$21:$A$32=$B5),--($C$21:$C$32=$C5))

    copied across and down.

    To hide 0 values, when there are no matches... format cells as Custom: 0;-0;;@

+ 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