[英]Find values in a worksheet with two criteria matches, copy them and paste them to another sheet with VBA
Here is my problem: 这是我的问题:
Sheet1 = "Interface". Sheet1 =“接口”。 Sheet2 = "Data". Sheet2 =“数据”。
Column C5:C160 in "Data" contains a list of tasks. “数据”中的列C5:C160包含任务列表。 Row D4:M4 in "Data" contains a list of position types (jobs), which I have labelled with "job categories" from 1-10. “数据”中的D4:M4行包含一个职位类型(职位)列表,我已用1-10的“职位类别”将其标记为。 The range D5:M160 contains work-hours for each task and position type. 范围D5:M160包含每个任务和职位类型的工作时间。
Values in columns E and F in "Interface" are related to columns C and row 4 in "Data" through data validation. 通过数据验证,“接口”中E和F列中的值与“数据”中C列和第4行相关。
What I want to do is create an advanced filter that can copy values from D5:M160 in "Data" and paste these in column G in "Interface", if the values in columns E and F "Interface" match the values in column C and row 4 in "Data" respectively, simultaneously. 我想做的是创建一个高级过滤器,如果E和F“接口”列中的值与C列中的值匹配,则可以从“数据”中的D5:M160复制值并将其粘贴到“接口”中的G列中。和“数据”中的第4行同时显示。
This means that it should be a macro to copy and paste values with matching multiple criteria (two criteria) from one sheet to another. 这意味着应该将宏与多个表(两个条件)相匹配的值复制和粘贴到一张纸上。
I have tried different things, with no success. 我尝试了不同的方法,但没有成功。 I have also tried array formulas, vlookup and sumifs with multiple criteria, but none of these seem work. 我还尝试了使用多个条件的数组公式,vlookup和sumifs,但这些方法似乎都不起作用。
Any ideas? 有任何想法吗?
I appreciate your help! 我感谢您的帮助!
The index
formula combined with match
is built just for this. index
公式与match
相结合就是为此而构建的。
Index
returns a value from a specified table when you provide a row and column. 提供行和列时, Index
从指定的表返回一个值。
Match
is used to return the row/column based on criteria. Match
用于根据条件返回行/列。
So on the Interface
sheet (assuming your data starts in Row 1) you can place the following formula in G1 and copy it down as needed. 因此,在“ Interface
表上(假设您的数据从第1行开始),您可以将以下公式放在G1中,并根据需要将其复制下来。
=INDEX(Data!$D$5:$M$160,MATCH(E1,Data!$C$5:$C$160,0),MATCH(F1,Data!$D$4:$M$4,0))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.