View Single Post
  #30  
Old 5th February 2012, 08:24 PM
Shaun Shaun is offline
Member
 
Join Date: Jan 1970
Location: Western Australia
Posts: 3,403
Default

The one main issue with doing this way is you lose the ability to refresh unless you run the macro again, I have not had a lot to do with refreshing a macro as I have not needed it so far but here is an option for auto refresh.

Add this code to the bottom of the module.

Code:
Sub RepeatMacro() Dim lastRunTime Do lastRunTime = Now Range("A2") = "Last run: " & Format(lastRunTime, "hh:nn:ss") Call Race DoEvents Application.Wait lastRunTime + TimeValue("00:00:01")' change the time to adjust the refresh rate Loop End Sub


Then you need to create 2 buttons to click so do this, select excel sheet where you have the race options , go to the top panel look for “Developer” if developer is not shown go to “File”/“Options”/”Customize Ribbon” and make sure it is checked on the right hand panel.
Select “Developer” then “Insert” then select “Command Button” in ActiveX Controls. Paste the button on the page then double click it then paste this between the top and botton line.
Code:
Call RepeatMacro

Repeat instructions to create another button and double click it and paste this in.
Code:
MsgBox "Stopped." End

You can then rename the buttons “StartButton” and “StopButton” you then need to activate them by pressing design mode to turn it off.
You can adjust the refresh time in “RepeatMacro” just press the buttons to start and stop refresh, you need to stop refresh before changing the race when you hit start it will switch races.
Reply With Quote