-1
Public Sub master()
    Dim checker As Date

    checker = Time
    If (checker > TimeValue("09:15:00")) & (checker <= TimeValue("12:00:00")) Then
        MsgBox "On time"
    Else
        MsgBox "Not the right time"
    End If

End Sub

It is giving an error on the if statement

"Type Mismatch" Run Time error 13

I have also tried Now, checker = Now

Community
  • 1
  • 1
Simz
  • 46
  • 4

1 Answers1

0

In VBA the & operator is for string concatenation. You need to use "and":

 If (checker > TimeValue("09:15:00")) and (checker <= TimeValue("12:00:00")) Then
razcor
  • 355
  • 2
  • 11