简体   繁体   English

在具有两个条件匹配项的工作表中查找值,将其复制并使用VBA将其粘贴到另一张表中

[英]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.

相关问题 VBA,使用条件将很多行复制并粘贴到另一个工作表中 - VBA, copy and paste lots of rows in another worksheet with a criteria 复制,粘贴基于多个条件的选择到VBA中的另一个工作表 - copy, paste selection based on multiple criteria to another worksheet in VBA VBA复制范围值并粘贴到另一张工作表中 - VBA Copy range values and paste in another sheet 如何复制一系列公式值并将它们粘贴到另一个工作表中的特定范围? - How do I copy a range of formula values and paste them to a specific range in another sheet? 复制M列中以“ xx”开头的单元格,然后将其粘贴到另一张表中 - Copy cells in column M that start with “xx” and paste them into another sheet VBA 将一张纸中的单元格相乘并将它们粘贴到另一张纸上 - VBA Multiply Cells in One Sheet and Paste Them to Another 如果满足两个范围标准,请复制第三个单元格并将其粘贴到另一张纸上 - If two range criteria are met, copy a third cell and paste it to another sheet 使用粘贴在某些条件下将单元格值从一张纸复制到另一张纸 - Copy Cell values from One Sheet to Another on certain criteria with the paste VBA复制并粘贴到另一个工作表 - VBA Copy and Paste to another sheet VBA复制工作表中的行,如果符合条件,则将其粘贴到其他工作表中 - VBA to copy row from worksheet and paste it into a different worksheet if criteria is met
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM