Using countdown timer to trigger macro

Please post any questions regarding the program here.

Moderator: 2020vision

Using countdown timer to trigger macro

Postby cic » Sat Mar 10, 2012 2:52 am

Could anyone tell me how i could use the countdown timer to trigger a macro. I have been messing around with change event though haven't succeeded. I would like for the macro named Solution to be triggered when the clock hits 00:01:05. Even a point in the right direction would be appreciated. Thanks in advance

Regards
Dan
cic
 
Posts: 14
Joined: Fri Mar 02, 2012 2:46 am

Postby Captain Sensible » Sat Mar 10, 2012 7:17 pm

You could stick the routine within a Worksheet_Calculate() or Worksheet_Change depending on how your sheets currently coded.

Something as simple as

Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
 
 
  If Range("D2").Value = TimeValue("00:01:05") Then
     Call Solution
  End If
 
 

 
End Sub




would work but I'd advise you to stick in additional flags to log the fact it's fired so your Macro Solution doesn't get triggered after each refresh. It's sometimes worth sticking in a range of times rather than an exact time as slow refreshes etc may mean you miss an exact time slot i.e.

If Range("D2").Value < TimeValue("00:01:05") And Range("D2").Value > TimeValue("00:00:55")Then
Call Solution
End If
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby Captain Sensible » Sat Mar 10, 2012 7:39 pm

Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
 
 
 
If Range("D2").Value < TimeValue("00:01:05") And Range("D2").Value > TimeValue("00:00:55") And Range("T1").Value <> "Fired" Then
     Call Solution
     Range("T1").Value = "Fired"
  End If
 
 

 
End Sub


The above would add a simple flag just by placing Fired in cell T1 to ensure you didn't loop Solution continually, you could then clear that either thru your other code or manually. Obviously you can change the time parameters to whatever you wanted
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby cic » Mon Mar 12, 2012 2:36 pm

Sorry been away, thanks for the replies will try them out now and let you know how i go. thanks again

Regards
Dan
cic
 
Posts: 14
Joined: Fri Mar 02, 2012 2:46 am

Postby cic » Mon Mar 12, 2012 2:51 pm

Worked beautifully thanks for your help. Much appreciated.

Regards
Dan
cic
 
Posts: 14
Joined: Fri Mar 02, 2012 2:46 am

Postby dixiedean » Thu Apr 12, 2012 10:43 am

Hi

I tried this and it works a treat except i cant stop my macro from repeating, any ideas on how to do this please?

Thanks

D
dixiedean
 
Posts: 28
Joined: Tue Sep 13, 2011 6:42 pm

Postby dixiedean » Fri Apr 13, 2012 4:34 pm

Private Sub Worksheet_Change(ByVal Target As Range)



If Range("D2").Value < TimeValue("00:01:05") And Range("D2").Value > TimeValue("00:00:55") And Range("T1").Value <> "Fired" Then
Call Solution
Range("T1").Value = "Fired"
End If




End Sub

How would i modify this to reset the fired cell at say time -00:01:00?

Thanks

D
dixiedean
 
Posts: 28
Joined: Tue Sep 13, 2011 6:42 pm

Postby Captain Sensible » Sat Apr 14, 2012 3:46 pm

It gets a bit awkward once the time goes negative as excel treats it as text rather than time.

Not sure why you'd want to use -00:01:00 though, that would assume the market is now in play but because start times rarely go off on time they'd be much better ways to do things if you wanted to reset after the market had been off/inplay for a minute.
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 78 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.