+ Reply to Thread
Results 1 to 5 of 5

Searching on two criteria

  1. #1
    Registered User
    Join Date
    11-13-2006
    Posts
    13

    Searching on two criteria

    Wow, I wasn't sure if I'd be able to find anyone able to help me out, and I was surprised to find this forum!

    Here's my problem... I have two search criteria that I need to search on, State, and Date.

    I have a separate sheet called "State" that has the table I need to search.
    The sheet has the columns State, Date, ContractNum, and is ordered alphabetically by State, then by Date.

    When I enter a State, and then a Date, I'd like it to find the state, then round down to the lower date, and then return the corresponding ContractNum.

    I've been searching the web for different functions I can use, but I can't seem to figure out a combination of functions that will work for me.
    Thanks for any help you can provide!

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by jdub765
    Wow, I wasn't sure if I'd be able to find anyone able to help me out, and I was surprised to find this forum!

    Here's my problem... I have two search criteria that I need to search on, State, and Date.

    I have a separate sheet called "State" that has the table I need to search.
    The sheet has the columns State, Date, ContractNum, and is ordered alphabetically by State, then by Date.

    When I enter a State, and then a Date, I'd like it to find the state, then round down to the lower date, and then return the corresponding ContractNum.

    I've been searching the web for different functions I can use, but I can't seem to figure out a combination of functions that will work for me.
    Thanks for any help you can provide!
    Hi,

    The easy way would be to insert a new column C on your lookup sheet, with =A1&B1 formula filled down the column.

    Your lookup can then be

    =If(Vlookup(A2,Sheet2!A$2:A$9999,1,False)<>A2,"",VLookup(A2&B2,Sheet2!C$2:D$9999,2,True))
    (untested) or something similar.

    Does this help you?
    ---
    Si fractum non sit, noli id reficere.

  3. #3
    Registered User
    Join Date
    11-13-2006
    Posts
    13
    I can't seem to get it to work correctly. It works okay if there aren't any other states, but once I include another state in the search, it just chooses the last date for the state Thanks for the help though!

  4. #4
    Valued Forum Contributor
    Join Date
    07-11-2004
    Posts
    851
    "The sheet has the columns State, Date, ContractNum, and is ordered alphabetically by State, then by Date"

    "When I enter a State, and then a Date, I'd like it to find the state, then round down to the lower date, and then return the corresponding ContractNum"

    if you just do a vlookup on the state won't it give you the contract number on the first entry of that state (and hence the lowest date)? Is that not what you desire? Or do you want the latest date for the state?
    not a professional, just trying to assist.....

  5. #5
    Registered User
    Join Date
    11-13-2006
    Posts
    13
    I want to look for a certain contract number based on the date of service and state.

    Like, if the service was performed in CA on 5/01/2002,
    A...B...........C
    AL 1/1/2006 342
    CA 1/1/2002 456
    CA 1/1/2003 567
    It should return "456".

    I figured out a formula that works...
    =INDEX(C2:C1000, MATCH(DateValue(K2),IF(A2:A1000=(J2),B2:C1000),1),1)
    Where K2 and J2 are my search values.

    I simplified the formula so it's more readable, but that's the gist of it.

    Thanks for your help guys! I'll probably be back soon with more questions
    Last edited by jdub765; 11-14-2006 at 04:46 PM.

+ 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