如何在vba中的特定时间更改单元格的值?

时间:2015-12-10 20:15:20

标签: excel vba excel-vba time

我正在尝试将单元格 B1 的值更改为" FALSE"下午1:00之后 这不起作用。

Sub MacroTimer()
    If Hour(Now) > 13 Then [B1].Value = "FALSE"
        ' Procedure to run timer sub.
        Module1.MacroTest
        ' Set last refresh time.
        [E1].Value = Time
        ' If cell B1 timer is true, run Macro again.
        If [B1].Value = "True" Then
            SetNextExecution
        Else
        Exit Sub
    End If

1 个答案:

答案 0 :(得分:0)

另一种宏观解决方案:

Sub ctrl()
    If Format(Hour(Now), "ss:dd") > Format("23:00", "ss:dd") Then
        [B1].Value = "FALSE"
    Else
        [B1].Value = "TRUE"
    End If
End Sub