Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 如果新电子表格中的数据与原始电子表格中的条件相匹配,则跨该数据进行复制_Excel_Excel Formula_Excel 2010 - Fatal编程技术网

Excel 如果新电子表格中的数据与原始电子表格中的条件相匹配,则跨该数据进行复制

Excel 如果新电子表格中的数据与原始电子表格中的条件相匹配,则跨该数据进行复制,excel,excel-formula,excel-2010,Excel,Excel Formula,Excel 2010,在Excel 2010中 2个不同的电子表格 If Column B (Name) is = to "ABC Co" 'from Sheet2 及 注:根据表2的示例,在B列(名称)和C列(类别)中可以找到重复值,在A列(零件#)中没有重复值 所需输出: *Sheet1* Column A Row 1 12340000 Row 2 12340003 提前非常感谢您的帮助,仅供参考,我花了相当多的时间搜索答

在Excel 2010中

2个不同的电子表格

If Column B (Name) is = to "ABC Co" 'from Sheet2

注:根据表2的示例,在B列(名称)和C列(类别)中可以找到重复值,在A列(零件#)中没有重复值

所需输出:

 *Sheet1*   

                 Column A
         Row 1   12340000
         Row 2   12340003
提前非常感谢您的帮助,仅供参考,我花了相当多的时间搜索答案,但没有任何运气,不太熟悉帮助我搜索所需的术语,并且调整以适应我的个人情况不是我的最佳优势。。。。希望没有我忽略的规则,但是如果是这样,请让我知道我很乐意纠正

您可以尝试以下方法:

我希望我的评论很清楚,否则就问我

选项显式

Sub MATCH()

Dim ws1 As Worksheet: Set ws1 = ThisWorkbook.Sheets("Sheet1") 'Change the name of the sheet
Dim ws2 As Worksheet: Set ws2 = ThisWorkbook.Sheets("Sheet2") 'Change the name of the sheet
Dim ws2Lastrow As Long, i As Long

ws2Lastrow = ws2.Range("A" & Rows.Count).End(xlUp).Row 'Find the lastrow in the Sheet(2)

With ws2 ' Work within the sheet(2)

For i = 2 To ws2Lastrow 'Start the Loop from row2 until the last row

'Put your two condition in order to copy the value in column Part#
' If the value in column B = "ABC Co" and column C = "A"
        If .Cells(i, "B").Value = "ABC Co" And .Cells(i, "C").Value = "A" Then

        'Past the value in Sheet(1) column A in the first empty cell
            ws1.Cells(ws1.Range("A" & Rows.Count).End(xlUp).Row + 1, "A") = .Cells(i, "A").Value

        End If

Next i

End With

End Sub
您可以尝试以下方法:

我希望我的评论很清楚,否则就问我

选项显式

Sub MATCH()

Dim ws1 As Worksheet: Set ws1 = ThisWorkbook.Sheets("Sheet1") 'Change the name of the sheet
Dim ws2 As Worksheet: Set ws2 = ThisWorkbook.Sheets("Sheet2") 'Change the name of the sheet
Dim ws2Lastrow As Long, i As Long

ws2Lastrow = ws2.Range("A" & Rows.Count).End(xlUp).Row 'Find the lastrow in the Sheet(2)

With ws2 ' Work within the sheet(2)

For i = 2 To ws2Lastrow 'Start the Loop from row2 until the last row

'Put your two condition in order to copy the value in column Part#
' If the value in column B = "ABC Co" and column C = "A"
        If .Cells(i, "B").Value = "ABC Co" And .Cells(i, "C").Value = "A" Then

        'Past the value in Sheet(1) column A in the first empty cell
            ws1.Cells(ws1.Range("A" & Rows.Count).End(xlUp).Row + 1, "A") = .Cells(i, "A").Value

        End If

Next i

End With

End Sub

你有没有理由不能只过滤你的结果?它们必须在单独的表格上吗?@Alicia你知道如何使用VBA吗?嗨,Chrismas007-没有VBA的经验:(嗨,马克-过滤是不可行的,因为有大约20个电子表格需要定期更新,从一个主要来源提取数据,而且我需要稍微修改公式,因为我有不止一种类型的条件需要搜索。有什么原因你不能只过滤你的结果吗?它们必须在单独的表格上吗?@Alicia你知道怎么做吗o使用VBA?Hi Chrismas007-没有VBA经验:(Hi-Marc-过滤不可行,因为有大约20个电子表格需要定期更新,从1个主要来源提取数据,而且我需要稍微修改公式,因为我有超过1种类型的条件需要搜索。Hi-Manu-非常感谢,我将很快尝试,并返回我的结果和/或问题!事实上,我只需要进一步看一下…这是VBA脚本吗?您好,Manu…刚刚检查了我的标签,发现里面有一个excel VBA,非常抱歉,我不知道我是如何添加的,因为我不熟悉VBA…我现在已经删除了…不知道您是否知道要使用公式?或者对于VBA,有没有简单的方法来解释如何输入这段代码?您好,Manu-非常感谢,我很快会尝试并返回我的结果和/或问题!实际上只是进一步查看…这是VBA脚本吗?您好,Manu…刚刚检查了我的标记并意识到其中有一个excel VBA,非常抱歉,我不知道我是如何添加的,因为我不熟悉VBA…我没有w删除…想知道您是否知道要使用的公式?或者对于VBA,有没有简单的方法来解释如何输入此代码?
Sub MATCH()

Dim ws1 As Worksheet: Set ws1 = ThisWorkbook.Sheets("Sheet1") 'Change the name of the sheet
Dim ws2 As Worksheet: Set ws2 = ThisWorkbook.Sheets("Sheet2") 'Change the name of the sheet
Dim ws2Lastrow As Long, i As Long

ws2Lastrow = ws2.Range("A" & Rows.Count).End(xlUp).Row 'Find the lastrow in the Sheet(2)

With ws2 ' Work within the sheet(2)

For i = 2 To ws2Lastrow 'Start the Loop from row2 until the last row

'Put your two condition in order to copy the value in column Part#
' If the value in column B = "ABC Co" and column C = "A"
        If .Cells(i, "B").Value = "ABC Co" And .Cells(i, "C").Value = "A" Then

        'Past the value in Sheet(1) column A in the first empty cell
            ws1.Cells(ws1.Range("A" & Rows.Count).End(xlUp).Row + 1, "A") = .Cells(i, "A").Value

        End If

Next i

End With

End Sub