简体   繁体   English

Excel VBA:多个查找值

[英]Excel VBA : Multiple lookup values

I have two sheets. 我有两张。 Result needed as in sheet1 Required Results column as depicted below. 所需的结果如sheet1的“ Required Results列中所示,如下所示。 The results are populated by checking the values in sheet2. 通过检查sheet2中的值来填充结果。

Noun      Modifier  Required Results                        Name1   Value1  Name2   Value2  Name3   Value3  Name4      Value4      Name4    Value4
ABRASIVE    BELT    ABRASIVE BELT : 5in X 2in               TYPE    WAFER   WIDTH           LENGTH  5in     THICKNESS   2in       DIAMETER   2m
ABRASIVE    BELT    ABRASIVE BELT : 11in X 6in X 3m         TYPE    LUGGED  WIDTH   11in    LENGTH  6in     THICKNESS   3in       DIAMETER   3m
ABRASIVE    BELT    ABRASIVE BELT : 12in X 7in X 3m         TYPE    LUGGED  WIDTH   12in    LENGTH  7in     THICKNESS   3in       DIAMETER   4m

Sheet2 工作表2

Noun      Modifier  Attribute Name    fill
ABRASIVE    BELT    TYPE                0
ABRASIVE    BELT    WIDTH               1
ABRASIVE    BELT    LENGTH              2
ABRASIVE    BELT    THICKNESS           3
ABRASIVE    BELT    DIAMETER            0
ABRASIVE    ROD     TYPE                0
ABRASIVE    ROD     LENGTH              1

I will explain the update process by taking first row as the example. 我将以第一行为例来说明更新过程。

  • ABRASIVE word from sheet1 is searched in sheet2 Noun column. 在sheet2名词列中搜索sheet1的粗略单词。
  • If Matches corresponding next value BELT from sheet1 is searched in sheet2 Modifier column. 如果匹配,则在sheet2修饰符列中搜索sheet1对应的下一个值BELT。
  • If both the values matches column Name1 value TYPE should be searched in sheet2 Attribute Name column. 如果两个值都匹配,则应在sheet2“ Attribute Name列中搜索“ Name1值TYPE。 If fill column is 0 for the corresponding row, then no need to populate the value in sheet1. 如果fill了相应的行栏为0,则没有必要填充在Sheet1中的价值。 Here in sheet 2 WIDTH, LENGTH, THICKNESS the values are 1 in fill column. 在第2页的WIDTH,LENGTH,THICKNESS中, fill列中的值为1。 Therefore I have concatenated WIDTH, LENGTH, THICHNESS values as 5in X 2 in. IN first row Width is blank. 因此,我将WIDTH,LENGTH,THICHNESS值串联为5in X 2 in。IN第一行中Width为空白。

So referring to Sheet two, I need to populate the dimensions. 因此,参考第二页,我需要填充尺寸。 I have around 10K records in sheet1 and 20K reference data in Sheet2. 我在sheet1中有大约1万条记录,在Sheet2中有2万条参考数据。 I tried applying several vlookup formulas, but I could not achieve it. 我尝试应用多个vlookup公式,但无法实现。 Please help. 请帮忙。

One simple way to make an unique identifier using several identifiers is to add the first column to the both of the sheets containing formula: 使用多个标识符制作唯一标识符的一种简单方法是将第一列添加到包含公式的两个工作表中:

="identifier-1"&"identifier-2"&...&"identifier-n" =“ identifier-1”&“ identifier-2”&...&“ identifier-n”

where "identifier-1", "Identifier-2" and "identifier-n" are cell addresses containing respective identifiers. 其中“ identifier-1”,“ Identifier-2”和“ identifier-n”是包含相应标识符的单元地址。

Using VLOOKUP formula with unique identifiers, desired data can be retrieved. 使用带有唯一标识符的VLOOKUP公式,可以检索所需的数据。

After populating data in Sheet1 Value1 through Value4, data can be joined in Dimension column using CONCATENATE function or "&" for merging values. 在Sheet1的Value1到Value4中填充数据之后,可以使用CONCATENATE函数或“&”合并值在Dimension列中合并数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM