+ Reply to Thread
Results 1 to 4 of 4

Multiple Criteria Index/Match Function in VBA Looking Up Dates/Strings/Numbers

  1. #1
    Registered User
    Join Date
    08-06-2012
    Location
    Providence, Rhode Island
    MS-Off Ver
    Excel 2007
    Posts
    6

    Multiple Criteria Index/Match Function in VBA Looking Up Dates/Strings/Numbers

    I cannot seem to get this to work and i am hoping one of the resident experts can shed some light on what i am doing wrong.

    Essentially, I am trying to use a combination of Index and Match functions from within VBA to identify multiple criteria and then return a related value from another column in the identified row. I have attached a sample file with the following 2 simple scenarios:

    On a Userform are 2 scenarios:

    Single Criteria [WORKING] - Selecting a date from the top combobox triggers the macro to match the selection with a column on the "Raw Data" sheet. It if there is a match it puts the corresponding value from column C ("Flag") into the top label on the userform.

    Multiple Criteria [NOT WORKING] - Selecting a date from the bottom combobox triggers the macro to match the selection with a column on the "Raw Data" sheet. It also attempts to match a string (stock symbol) from the "Main" worksheet in A2 to a column on the "Raw Data" worksheet. The bottom label on the userform should only show a value if both criteria are met.

    After spending some time on this and learning about the behavior of the Match function in VBA i think i have gotten very close... but i am still missing something. Hopefully it is syntax related. Any help would be greatly appreciated!

    Single Criteria Code[Working]:
    Please Login or Register  to view this content.
    Multiple Criteria Code [Not Working]:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Multiple Criteria Index/Match Function in VBA Looking Up Dates/Strings/Numbers

    You already have multiple criteria, even in your single criteria code.
    In your Sub ShowSecondForm() code, you already limit the date values ( in NoDupes collection) to those in regard of the symbol in cell A2 of your Main sheet.
    Or there is something I don't understand.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Registered User
    Join Date
    08-06-2012
    Location
    Providence, Rhode Island
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Multiple Criteria Index/Match Function in VBA Looking Up Dates/Strings/Numbers

    Hi Pierre,

    Thank you for your response.

    You are correct that i am already limiting the date values that get populated into the userform comboboxes based on that symbol from the "Main" worksheet. And i realize that my code may be primitive as i go about trying to achieve what i want but this is just how i am trying to muscle through it.

    I am pulling this functionality from a larger more complex project, but basically assume there would be a listbox on the main page with a bunch of stock symbols in it. The user selects one and then has some various menus (userforms) that can be brought up with supporting information based on whatever stock symbol is selected. The Raw data worksheet could have 10,000 rows of data for 100 different stocks. I want to be able to query that large data set(like you would in Access) by multiple criteria. So my thinking is, I have a symbol highlighted in a listbox on the main sheet which is one of the criteria I wish to use. I bring up a userform that allows me to select a second criteria related to that highlighted symbol (The unique dates that were added through the No Dupes collection). I then wish to query the raw data sheet using both pieces: the symbol from the main sheet and the date (or whatever) from the userform combobox. I want the result (the flag in this case) to appear in the label on the userform.

    So if for example you insert a row between 1 & 2 on the raw data sheet and put an identical date with a different symbol and flag(say "AAPL" & "N"), the userform combobox macro would see the date and return the wrong flag because it wasnt also referencing the selected symbol criteria from the main sheet.

    It sounds simple in my head and when i write it out like this... but i am having trouble getting it to work.

  4. #4
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Multiple Criteria Index/Match Function in VBA Looking Up Dates/Strings/Numbers

    I'm not sure how and where to do this in your form but you should look into the Scripting Dictionary class.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Using MATCH and INDEX function with multiple criteria
    By Babylon in forum Excel Programming / VBA / Macros
    Replies: 52
    Last Post: 02-06-2014, 11:28 AM
  2. INDEX MATCH with multiple same dates
    By mcayea in forum Excel Formulas & Functions
    Replies: 23
    Last Post: 07-08-2013, 10:58 AM
  3. Replies: 3
    Last Post: 05-02-2013, 01:31 AM
  4. Index and match function multiple criteria
    By mfortier3 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-16-2013, 05:27 AM
  5. SOS:Return multiple values against multi criteria match and index function
    By nitesh_inin in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 11-26-2012, 05:45 PM

Tags for this Thread

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