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.)
相关问题
- Excel sunburst chart: Some labels missing
- Error handling only works once
- Error handling only works once
- Excel formula in VBA code
- Excel VBA run time error 450 from referencing a ra
相关文章
- Get column data by Column name and sheet name
- programmatically excel cells to be auto fit width
- Unregister a XLL in Excel (VBA)
- Unregister a XLL in Excel (VBA)
- How to prevent excel from truncating numbers in a
- numeric up down control in vba
- Declare a Range relative to the Active Cell with V
- What's the easiest way to create an Excel tabl
You dont need any VBA for such a simple thing. Use this array formula:
Dont forget to enter the formula with Ctrl Shift Enter (it is an array formula)
Concatenate week and number of devices and then search like usual one keyword search.
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 withSUMPRODUCT
.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.Multiple Column vs Multiple Column Lookup *
Multiple-column based lookups in Excel *
Lookup Database (Multiple criteria)
Excel Lookup with multiple queries
Multiple VLOOKUP LOOKUP IF Statement?
Returning a value if three columns match in excel *
VLookup multiple columns
Comparing two columns in one Excel sheet, to two columns in another sheet, and if they match, copy data from another column *
Macro for vlookup with 2 vertical criteria *
http://spreadsheets.about.com/b/2014/01/08/excel-lookup-formula-using-multiple-criteria.htm
http://fiveminutelessons.com/learn-microsoft-excel/use-index-lookup-multiple-values-list
http://blogs.office.com/2012/04/26/using-multiple-criteria-in-excel-lookup-formulas/
http://www.xl-central.com/lookup-multiple-criteria.html
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