我想用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