Searching an excel with two search words (multiple lookup) using vba macro

Gauranga

I am using vba macros.
Task:
1) User will give two inputs viz. number of devices sold (column B) and week number (column A).
2) Search the excel file using these two and get the earnings.

(Conditions:
1. We dont have to modify anything in the excel file.
2.And we have to first search devices sold and then we can go to week number.)

Note: Actually i have a different problem, this is generalization for that.

I used find function but I dont understand why its working.

Please tell what is to be done.


Consider the input is 11 and week 3 (so search for 11 and then check if its corresponds to week 3 or not. If not, move to next. I tried this but ended up in an infinite loop.)


enter image description here

sancho.s ReinstateMonicaCellio

You are looking for a Lookup with multiple criteria. A quick search gives several useful links, listed below. I have marked with * those that I have answered. I have filtered out some of the links that actually deal with other issues.

As seen in the links, there are several options to achieve your goal. I personally prefer those that do not need array formulas, using an answer to question 1 with LOOKUP or an answer to question 2 with SUMPRODUCT.

Since you mentioned that you need a VBA solution, you can use WorksheetFunction to use an Excel formula in VBA code, or check answers to question 7.

  1. Multiple Column vs Multiple Column Lookup *

  2. Multiple-column based lookups in Excel *

  3. Lookup Database (Multiple criteria)

  4. Excel Lookup with multiple queries

  5. Multiple VLOOKUP LOOKUP IF Statement?

  6. Returning a value if three columns match in excel *

  7. VLookup multiple columns

  8. Comparing two columns in one Excel sheet, to two columns in another sheet, and if they match, copy data from another column *

  9. Macro for vlookup with 2 vertical criteria *

  10. http://spreadsheets.about.com/b/2014/01/08/excel-lookup-formula-using-multiple-criteria.htm

  11. http://fiveminutelessons.com/learn-microsoft-excel/use-index-lookup-multiple-values-list

  12. http://blogs.office.com/2012/04/26/using-multiple-criteria-in-excel-lookup-formulas/

  13. http://www.xl-central.com/lookup-multiple-criteria.html

  14. http://www.get-digital-help.com/2012/05/22/lookup-multiple-values-in-different-columns-and-return-a-single-value/

PS: The (probably partial) list of (probably) duplicated questions provided above shows the usefulness of what was proposed in https://meta.stackexchange.com/questions/211366/group-duplicate-questions-for-convenience

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Excel VBA Macro: Searching For Blank From Selection

From Dev

Searching over multiple columns in excel vba

From Dev

Excel VBA using Range in Macro

From Dev

Search in Excel using VBA

From Dev

Excel: Search multiple columns for multiple words

From Dev

Extract english dictionary words using macro in excel

From Dev

VBA macro that search for file in multiple subfolders

From Dev

Searching words in two column

From Dev

Searching Outlook email (and replying to it) using Excel VBA

From Dev

MongoDB - Logical OR when searching for words and phrases using full text search

From Dev

Excel VBA - Using lookup formula for a dynamic range

From Dev

Excel VBA - Using lookup formula for a dynamic range

From Dev

Using VBA in Excel to Google Search

From Dev

Excel Lookup - two criteria using MATCH

From Dev

EXCEL VBA Macro: Can this be simplified using Range?

From Dev

VBA/Excel macro - trying to simplify code using an array that draws from one worksheet and populates across multiple worksheets

From Dev

Python searching for two words regex

From Dev

Grep searching two words in a line

From Dev

Tagging Words Using VBA in MS Excel

From Dev

Split words using VBA in Excel cells

From Dev

Using Grep to search for multiple words in a file

From Dev

Using Grep to search for multiple words in a file

From Dev

EF filtering/searching with multiple words

From Dev

Mysql, PHP, searching for multiple words

From Dev

Searching multiple patterns (words) with ack?

From Dev

EF filtering/searching with multiple words

From Dev

Excel vba macro to connect to a particular webpage - search and retrieve data

From Dev

Freeze multiple columns in excel using macro

From Dev

Search using single input while searching multiple tables

Related Related

  1. 1

    Excel VBA Macro: Searching For Blank From Selection

  2. 2

    Searching over multiple columns in excel vba

  3. 3

    Excel VBA using Range in Macro

  4. 4

    Search in Excel using VBA

  5. 5

    Excel: Search multiple columns for multiple words

  6. 6

    Extract english dictionary words using macro in excel

  7. 7

    VBA macro that search for file in multiple subfolders

  8. 8

    Searching words in two column

  9. 9

    Searching Outlook email (and replying to it) using Excel VBA

  10. 10

    MongoDB - Logical OR when searching for words and phrases using full text search

  11. 11

    Excel VBA - Using lookup formula for a dynamic range

  12. 12

    Excel VBA - Using lookup formula for a dynamic range

  13. 13

    Using VBA in Excel to Google Search

  14. 14

    Excel Lookup - two criteria using MATCH

  15. 15

    EXCEL VBA Macro: Can this be simplified using Range?

  16. 16

    VBA/Excel macro - trying to simplify code using an array that draws from one worksheet and populates across multiple worksheets

  17. 17

    Python searching for two words regex

  18. 18

    Grep searching two words in a line

  19. 19

    Tagging Words Using VBA in MS Excel

  20. 20

    Split words using VBA in Excel cells

  21. 21

    Using Grep to search for multiple words in a file

  22. 22

    Using Grep to search for multiple words in a file

  23. 23

    EF filtering/searching with multiple words

  24. 24

    Mysql, PHP, searching for multiple words

  25. 25

    Searching multiple patterns (words) with ack?

  26. 26

    EF filtering/searching with multiple words

  27. 27

    Excel vba macro to connect to a particular webpage - search and retrieve data

  28. 28

    Freeze multiple columns in excel using macro

  29. 29

    Search using single input while searching multiple tables

HotTag

Archive