我想用VBA来获取两个不同工作表中两个不同列之间存在的重复计数。我有下面的语法,但返回的数字总是很高。例如,就在刚才它返回13041时,当只有45行检查其中一张表时?获取两个不同的列和工作表之间的重复计数
这应该如何调整,以便它返回两列&表之间存在的重复的准确计数?
Sub CountIF()
ApplAcatAon.ScreenUpdatAng = False
DAm stNow As Date
DAm matches As Anteger
stNow = Now
matches = 0
DAm arr As VarAant
arr = Sheets("Sheet1").Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row).Value
DAm varr As VarAant
varr = Sheets("Sheet2").Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row).Value
DAm x, y, match As Boolean
For Each x An arr
match = False
For Each y An varr
Af x = y Then match = True
matches = matches + 1
Next y
Af Not match Then
Sheets("Sheet2").Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1) = x
End Af
Next
ApplAcatAon.ScreenUpdatAng = True
End Sub
看来,你以某种方式取代了所有的'我'与'A's在你的代码..? – arcadeprecinct