简体   繁体   English

Excel:基于工作表1中的数据创建自定义工作表2

[英]Excel: Create Custom Sheet 2 Based on Data in Sheet 1

I have two sheets in a spreadsheet. 电子表格中有两张纸。 Each sheet has a first column with common values (however they are not sorted the same and they are not all there in each sheet). 每张工作表都有一列具有共同值的列(但是,它们的排序方式不同,并且在每张工作表中都没有全部列出)。

What I'm trying to do, if possible, is put a formula in sheet 2, where, if column 1 is a match for sheet 1, copies selective data from certain columns in that same row in sheet 1, to certain columns in sheet 2. 如果可能的话,我想做的是在工作表2中放置一个公式,如果第1列与工作表1相匹配,则将选择数据从工作表1中同一行的某些列复制到工作表中的某些列2。

Example: 例:

Sheet 1 has a heading setup and sample data row like this: 表格1具有标题设置和示例数据行,如下所示:

Title | 标题| Day of Week | 星期几| First | 第一| Last 持续

Supervisor | 主管| Wednesday | 星期三| Mike | 迈克| Jones 琼斯

Sheet 2 has a heading setup and sample data row like this: 表格2具有标题设置和示例数据行,如下所示:

Title | 标题| Surname | 姓| Weekday 平日

Supervisor | 主管| (empty cell) | (空单元格)| (empty cell) (空单元格)

After running the mystery formula I'm looking for, placed in the 2 empty cells above, sheet 2 should match on the Supervisor key in sheet 1 and copy in data I have specified into each column, such as: 在运行我要寻找的神秘公式之后,将其放在上面的2个空白单元格中,工作表2应该与工作表1中的Supervisor键匹配,并将我指定的数据复制到每列中,例如:

Title | 标题| Surname | 姓| Weekday 平日

Supervisor | 主管| Jones | 琼斯| Wednesday 星期三

(In this case I have told it to map the "day of week" column to weekday, and map the "last" column to "surname"). (在这种情况下,我告诉它将“星期几”列映射到工作日,并将“最后”列映射到“姓”)。

I hope this is easy/possible??? 我希望这是容易/可能的??? Help??? 救命???

VBA is not necessary. 不需要VBA。 You can use a simple VLOOKUP: 您可以使用简单的VLOOKUP:

=VLOOKUP(cell to look-up, range where you want to look up the values (first column *must* contain the keys to look-up) including all columns that you want to retrieve, the position of the column to be retrieved relative to the first column specified in argument 2, 0 (specifies you want an exact match))

For example: 例如:

=VLOOKUP(A1, Sheet1!$A$1:$D$150, 2, 0) ' Retrieves the 2nd column matching criteria in A1

Please notice, however, that you need your keys to be unique. 但是请注意,您需要密钥是唯一的。 Matching information based on the title seems a bit odd since it is likely there will be more than one person assigned to a certain role. 基于标题的匹配信息似乎有些奇怪,因为分配给某个角色的人可能不止一个。 For example, there may be more than 1 supervisor. 例如,可能有不止一名主管。

Use INDEX and MATCH (better than VLOOKUP). 使用INDEX和MATCH(优于VLOOKUP)。

I suggest renaming your headers so they match on both sheet. 我建议重命名标题,以便它们在两个表上都匹配。

Sheet 1 should be : 表格1应该是:

Title | 标题| Weekday | 平日| First Name | 名| Surname

In sheet 2, cell B2 type in 在工作表2中,输入单元格B2

=INDEX(Sheet1!$A:$D,match($A2,Sheet1!$A:$A,0),match(B$2,Sheet1!$1:$1,0))

You can drag and drop it in column C as well, it will work since you are using two MATCH functions with the cells properly anchored. 您也可以将其拖放到C列中,因为您正在使用两个MATCH函数并将单元正确锚定,所以它可以工作。

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

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