0

I am trying to change the value of cell B1 to "FALSE" after 1:00 PM.
This is not working.

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
Deduplicator
  • 44,692
  • 7
  • 66
  • 118
  • You have to use [Application.OnTime](http://stackoverflow.com/questions/17301512/how-to-use-application-ontime-to-call-a-macro-at-a-set-time-everyday-without-ha) – A.S.H Dec 10 '15 at 20:26
  • 3
    dumb question: why not directly put in the cell: `=IF(HOUR(NOW())>=13,"FALSE","TRUE")`? – Dirk Reichel Dec 10 '15 at 20:34
  • You're overcomplicating it.. – AStopher Dec 10 '15 at 20:52
  • 1
    @DirkReichel couldn't you just simplify it to `=HOUR(NOW())<=13` – Scott Craner Dec 10 '15 at 21:12
  • 1
    @ScottCraner yes and no... asuming he has a german client `=HOUR(NOW())<=13` would print `WAHR` and `FALSCH` but he may need `TRUE` and `FALSE`... having `...[B1].Value = "FALSE"` shows that he doesn't want `...[B1].Value = False`... – Dirk Reichel Dec 10 '15 at 21:20
  • I did try putting =IF(HOUR(NOW())>=13,"FALSE","TRUE" in the cell, but the value of B1 determines if my next macro will run. See- If [B.1].Value = "true" Then SetNextExecution. If the value of B1 is a formula, it doesn't work. Basically, if B1 is "true" then the next set of macros will loop every 5 minutes.At 1PM I want B1 to change to "False", which will stop the loop and exit the sub. You are correct @DirkReichel this is global so it must remain English. – Cassi B Dec 11 '15 at 15:33

1 Answers1

0

An alternative macro solution:

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
monelogg
  • 11
  • 2