我正在尝试遍历指定数量的单元格(由宽度和高度定义),但我在这里遇到了问题。它一直在我身上停滞不前,然后对以下内容感到不安:
If .Cells(11 + row, col).Value > maxVal Then
它给了我一个“应用程序定义或对象定义错误”
谁能告诉我我的代码哪里出错了:
Sub ApplyFilter()
Dim maxVal As Double
Dim minVal As Double
maxVal = ActiveSheet.Range("D10").Value
minVal = ActiveSheet.Range("D11").Value
Dim width As Integer
Dim height As Integer
width = ActiveSheet.Range("L3").Value
height = ActiveSheet.Range("L4").Value
Dim row As Integer
Dim col As Integer
ActiveSheet.Select
With Selection
row = 1
Do
col = 1
Do
If .Cells(11 + row, col).Value > maxVal Then
.Cells(11 + row, col).Value = 0
End If
If .Cells(11 + row, col).Value < minVal Then
.Cells(11 + row, col).Value = 0
End If
col = col + 1
width = width - 1
Loop Until width = 1
row = row + 1
height = height - 1
Loop Until height = 1
End With
End Sub