Macro to run IF the current time is before 17:00 only

  • I have a macro that sends out five emails. I want them to send one of the emails only if the time is before 5pm - i.e. i need an if statement that says if the time is before 5pm, carry on, otherwise, ignore.

  • Re: Macro to run IF the current time is before 17:00 only


    You could use Time

    Code
    Dim endTime As Date
    endTime = "17:00"
            If Time < endTime Then
                          ......send email code
            Else
                          MsgBox "Too late to send emails", vbCritical
            End If

    Regards
    [SIZE=3]Anthony
    [/SIZE]&WCF_AMPERSAND[SIZE=3]
    [/SIZE]&WCF_AMPERSAND&WCF_AMPERSAND&WCF_AMPERSAND[SIZE=2]You have your way. I have my way. As for the right way, the correct way, and the only way, it does not exist.[/SIZE]




Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!