Timer

Solstice

New Member
Joined
Mar 12, 2022
Messages
6
Office Version
  1. 2016
Platform
  1. Windows
I am trying to make a timer. There is a type mismatch error.

VBA Code:
Option Explicit
Public TimerValue As Variant
Public ticker As Variant
Sub Start_Click()
    ticker = Now
    MacroRun
End Sub
Sub MacroRun()
    Application.DisplayAlerts = False
    TimerValue = Timer
    Do Until Timer > TimerValue + 60
      
    Loop
    Tick
    Application.DisplayAlerts = True
End Sub
Sub Tick()
    If (DateValue("03/12/2022") + TimeValue(Cells(3, 3).Value & ":" & Cells(3, 4).Value & ":" & "0")) > Now() Then 'error type mismatch
        MacroRun
    Else
        Alarm
        Exit Sub
    End If
End Sub
Sub Alarm()
    Cells(1, 2) = "Alarm
End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I am trying to make a timer. The type mismatch error is gone but it still has an Object error .

VBA Code:
Option Explicit
Public TimerValue As Variant
Public ticker As Variant
Sub Start_Click()
    ticker = Now
    MacroRun
End Sub
Sub MacroRun()
    Application.DisplayAlerts = False
    TimerValue = Timer
    Do Until Timer > TimerValue + 60
     
    Loop
    Tick
    Application.DisplayAlerts = True
End Sub
Sub Tick()
    If (DateValue("03/12/2022").Value + TimeValue(Cells(3, 3).Value & ":" & Cells(3, 4).Value & ":" & "0")) > Now() Then 'object error
        MacroRun
    Else
        Alarm
        Exit Sub
    End If
End Sub
Sub Alarm()
    Cells(1, 2) = "Alarm
End Sub
 
Upvote 0
Not functioning the way I want. It gives a "Object error"
VBA Code:
If (DateValue("03/12/2022").Value + TimeValue(Cells(3, 4).Value & ":" & Cells(4, 4).Value & ":" & "0").Value) > Now.Value Then
 
Upvote 0
VBA Code:
If DateValue("03/12/2022") + TimeSerial(Cells(3, 4).Value, Cells(4, 4).Value, 0) > Now Then
 
Upvote 0
@Solstice, your syntax isn't correct, since VBA's TimeValue, DateValue and Now functions don't have a member called Value.

Rich (BB code):
If (DateValue("03/12/2022").Value + TimeValue(Cells(3, 4).Value & ":" & Cells(4, 4).Value & ":" & "0").Value) > Now.Value Then
 
Upvote 0

Forum statistics

Threads
1,217,414
Messages
6,136,496
Members
450,016
Latest member
murarj

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top