在Excel 2010中
2个不同的电子表格
If Column B (Name) is = to "ABC Co" 'from Sheet2
和
If Column C (Category) is = to "A" 'from Sheet2
Copy "Part#" from Column A (Sheet2) into Sheet1
注意:根据Sheet2上的示例,可以在B列(名称)和C列(类别)中找到重复值,A列中没有重复(部件号)
**Sheet2**
Column A Column B Column C
Row 1 Part# Name: Category:
Row 2 12340000 ABC Co A
Row 3 12340001 DDD Inc A
Row 4 12340002 Alpha Co A
Row 5 12340003 ABC Co A
Row 6 12340004 Alpha Co B
Row 7 12340005 DDD Inc B
Row 8 12340006 ABC Co B
需要输出:
*Sheet1*
Column A
Row 1 12340000
Row 2 12340003
非常感谢你提前帮助,仅仅是一个FYI,我花了很多时间寻找答案但是没有运气,不太熟悉协助我的术语搜索和调整以适应我个人的情况不是我最好的力量....希望没有我忽略的规则,如果是这样,如果你能告诉我,我会很乐意纠正。
答案 0 :(得分:0)
你可以试试这个:
我希望我的意见清楚,否则就问我。
选项明确
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