【发布时间】:2018-03-09 05:58:56
【问题描述】:
我在 sheet4 中有要查找的单元格,查找表在 sheet2 Range("A16:B25") 中。当我运行这段代码时,它给了我一个mismatch error。为什么要这样做?
Dim i As Integer
Dim lrow As Long
Dim x As Integer
Sheet4.Activate
lrow = Sheet4.Range("A" & Rows.count).End(xlUp).Row
For i = 2 To lrow
Cells(i, 1).Activate
x = Application.VLookup(ActiveCell.Offset(0, 0).Value, Worksheets(2).Range("A16:B25"), 2, False)
If x <> Cells(i, 2).Value Then
Cells(i, 2).Interior.Color = RGB(255, 0, 0)
Else
End If
Next i
【问题讨论】:
-
那是因为它找不到范围内的值,它试图在一个整数中输入一个错误。
-
请告诉我如何解决这个问题。非常感谢,因为我是 vba 的新手