如何在可见范围内find单元格值

我有一长串的条目要很快地通过,其中一列F列经常改变。 由于我要逐个查看每个条目,因此我想要突出显示F行中值变化的整个行,以便于查看。 这是我迄今为止写的:

Dim visRng As Range, rngTop As Long, rngBot As Long rngTop = ActiveWindow.visiblerange.Row rngBot = ActiveWindow.visiblerange.Row + ActiveWindow.visiblerange.Rows.Count - 2 visRng = Worksheets("Work").Range("F" & rngTop, "F" & rngBot) For Each Cell In visRng If Cell.Value = Cell.Offset(-1).Value _ And Cell.Interior.ColorIndex = 0 Then Cell.EntireRow.Interior.ColorIndex = 3 End If Next 

我一直在我定义“visRng”的行上发生错误:

运行时错误“91”:对象variables或块variables未设置

我对VBA相当陌生,自学成才,所以我不能保证我会理解所有的行话。 任何帮助是极大的赞赏!

见解释说明。

 Sub FindAndColor() Dim visRng As Range Dim rngCell As Range '/ Set to range object. Yiu can't simply asign to it. '/ This will get rid of Error 91 '/ Just Use VisibleCells of the usedRange Set visRng = Worksheets("Work").UsedRange.SpecialCells(XlCellType.xlCellTypeVisible) '/ Loop through the range For Each rngCell In visRng.Cells If rngCell.Row <> 1 Then If rngCell.Value = rngCell.Offset(-1).Value _ And rngCell.Interior.ColorIndex = -4142 Then '/ -4142 is the default interior colorindex rngCell.EntireRow.Interior.ColorIndex = 3 End If End If Next End Sub