在VBA Excel中使用范围方法时出错(参数设置)

时间:2019-03-26 05:27:23

标签: excel vba

我声明了ColorCell变量并使用Set以便使用For循环进行一些颜色更改。

但是在编码时会引发错误,我无法解释调试说明。

Sub 계산()    
    Dim SumVariable As Integer
    Dim i As Integer
    Dim ColorCell As Range
    Set ColorCell = Range("D" & i)

    For i = 3 To Range("D14").End(xlUp).Row
        If Cells(i, "D") > 300 Then
            MsgBox ("haha!")

            Cells(i, "D").Value = 10
            Range("D4").CurrentRegion.Select
            ColorCell.Interior.Color = vbYellow                
        End If
    Next i    
End Sub

0 个答案:

没有答案