• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Need macro

Abhijeet

Active Member
Hi

I want for this formula =RANDBETWEEN(1,10000) refresh every after 2 min for this I want macro please help for this
 
Hi

Try

Code:
Option Explicit
Dim NextTick As Date
Sub StartRefresh()
   
    GetRefreshed
End Sub
Private Sub GetRefreshed()
   
    Dim rngFormula  As Range
   
    Set rngFormula = Sheet1.Range("c3") '<<< adjust the range
   
    rngFormula.Calculate
   
    NextTick = Now + TimeValue("00:02:00")
    Application.OnTime NextTick, "GetRefreshed"
End Sub
Sub StopClock()
   
    On Error Resume Next
    Application.OnTime earliesttime:=NextTick, procedure:="GetRefreshed", schedule:=False
    On Error GoTo 0
End Sub
 
Abhijeet, based on what Kris has written, it is imperative that the code is run from a code module, and not from a sheet / workbook code module.

I've used Kris's code here (just changed the 2 minutes to 2 seconds cause I get bored easily ;))
 

Attachments

  • Start And Stop Random Generator.xlsm
    15.3 KB · Views: 3
Back
Top