使用vba宏搜索具有两个搜索词(多个查找)的excel [英] Searching an excel with two search words (multiple lookup) using vba macro
问题描述
我正在使用vba宏。
任务:
1)用户将给出两个输入。销售的设备数量(B列)和周数(A列)。
2)使用这两个文件搜索excel文件并获得收入。
(条件:
1.我们不必修改excel文件中的任何内容。
2.我们必须首先搜索销售的设备
,然后我们可以去周号
。)
注意:其实我有一个不同的问题,这是一般的。
我使用找到
功能,但我不明白为什么它的工作。
请告诉要做什么
考虑输入是 11
和第3周
(所以搜索 11
,然后检查它是否对应于第3周
,否则移动到下一个我尝试过,但最终在无限循环中。)
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.)
推荐答案
你正在寻找一个查找与多iple标准。快速搜索提供了几个有用的链接,如下所列。我已经标记了*我已经回答的那些。
我已经滤除了实际处理其他问题的一些链接。
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.
如链接中所示,有几个选项实现你的目标我个人更喜欢那些不需要数组公式,使用问题1的答案与 LOOKUP
或问题2的答案与 SUMPRODUCT
。
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
.
由于您提到需要VBA解决方案,您可以使用 WorksheetFunction
在VBA代码中使用Excel公式,或检查问题7的答案。
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.
http://spreadsheets.about.com/b/2014/01/08/excel-lookup-formula-using-multiple-criteria.htm
http:// fiveminuteles sons.com/learn-microsoft-excel/use-index-lookup-multiple-values-list
http://blogs.office.com/2012/04/ 26 / using-multiple-criteria-in-excel-lookup-formula /
http://www.xl-central.com/lookup-multiple-criteria.html
PS:(可能是部分的) )上面提供的重复问题显示了在 https://meta.stackexchange.com/questions/211366/group-duplicate-questions-for-convenience
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
这篇关于使用vba宏搜索具有两个搜索词(多个查找)的excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!