0
任何人都可以解釋爲什麼有類型不匹配如果範圍...運行?
這裏是我的代碼類型不匹配錯誤,爲什麼?
Sub Button2_Click()
Dim i As Integer
Dim k As Integer
For i = 2 To 1000
For x = 3 To 999
If Range("k" & i & ":bn" & i).Value = Range("k" & x & ":bn" & x).Value And Cells(i, 5).Value <> Cells(x, 5).Value Then
Range("k" & i & ":bn" & i).Interior.ColorIndex = 7
Range("k" & x & ":bn" & x).Interior.ColorIndex = 7
End If
Next x
Next i
End Sub
我試圖用Cstr()
,但什麼都沒有改變
UP:我試圖用一個多循環和細胞的替代範圍,只有我拿到的是應用程序定義或對象定義的錯誤是:
Dim z As Integer
...
For z = 6 To 30
If Cells(i, z).Value = Cells(x, z).Value And Cells(i, 5).Value <> Cells(x, 5).Value Then
TNX提前
你不能像這樣比較整個範圍:'Range(「K2:BN2」)。Value = Range(「K3:BN3」)。Value。看到這個問題如何做到這一點:http://stackoverflow.com/questions/19395633/how-to-compare-two-entire-rows-in-a-sheet/19396257#19396257 –
@simoco我可以使用單元格( ).value代替? – Seya
您可以只比較_one_ cell與_another_ cell。但是你不能以這種方式比較_entire ranges_。如果您需要比較整個範圍 - 請參閱上面給出的鏈接 –