vba 在另一个工作簿中查找匹配的单元格值并返回匹配的行内容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6788509/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
find matching cell value in another workbook and return matching row content
提问by noni
I'm new to Excel and VBA and am faced with the following task:
我是 Excel 和 VBA 新手,面临以下任务:
I have two workbooks - wookbook1.xlsx
contains company names and will hold a macro, and workbook2.xlsx
which will hold the values I need to match against from workbook1
. For each company name in workbook1
, I need to get the row value where a match is found in workbook2
.
我有两个工作簿 -wookbook1.xlsx
包含公司名称,并将包含一个宏,它将包含workbook2.xlsx
我需要匹配的值 from workbook1
. 对于 中的每个公司名称workbook1
,我需要获取在 中找到匹配项的行值workbook2
。
Please help.
请帮忙。
回答by JMax
As iDevlop pointed out in his/her comment, you don't have to use vba but rather a formula.
正如 iDevlop 在他/她的评论中指出的那样,您不必使用 vba 而是使用公式。
Here are a few links to help you in building the right formula:
以下是一些可帮助您构建正确公式的链接:
- The
VLOOKUP
formula will help you find the matching value in another array: http://www.techonthenet.com/excel/formulas/vlookup.php - The
INDEX
formula will help you find the corresponding row or column (a.k.a. index) in another array: http://www.contextures.com/xlfunctions03.html
- 该
VLOOKUP
公式将帮助您在另一个数组中找到匹配的值:http: //www.techonthenet.com/excel/formulas/vlookup.php - 该
INDEX
公式将帮助您在另一个数组中找到相应的行或列(又名索引):http: //www.contextures.com/xlfunctions03.html
If you can't get it, please edit your first post with what you tried and a deeper example of what you are trying to do.
如果您无法理解,请编辑您的第一篇文章,其中包含您尝试过的内容以及您正在尝试做的更深入的示例。
Regards,
问候,