计算最后使用的行时出现错误1004

时间:2019-06-16 06:11:05

标签: excel vba

为什么从“ lastrow = ...”开始的第三行被标识为错误“ 1004”运行时错误?

Sub createNotifications()

    Dim i As Long, lastrow As Long

    lastrow = Sheet1.Cells(Rows.Count, 1).End(x1up).Row

    For i = 2 To lastrow

        Cells(i, 3).Value = Cells(i, 2) - 3
        If Cells(i, 3) - Date Then
            Cells(i, 3).Interior.ColorIndex = 3
            Cells(i, 3).Font.ColorIndex = 2
            Cells(i, 4).Value = "send Reminder"

        Else

            Cells(1, 3).Font.ColorIndex = vbBlack
            Cells(1, 3).Interior.ColorIndex = 2
            Cells(1, 4).Value = ""

        End If

    Next

End Sub

0 个答案:

没有答案