Expert Required

  • Thread starter Thread starter ceemo
  • Start date Start date
C

ceemo

I have a workbook containing 5 imported tables that i want to refresh
every hour at 20 minutes past the hour.

The below code will only refresh them once at 20 minutes past.


Plese can you help me adapt this code to keep refreshing tem every hour
at 20 past?




Option Explicit

Dim dNext As Date

Sub Auto_Open()

dNext = TimeSerial(Hour(Now) + IIf(Minute(Now) < 20, 0, 1), 20, 0)
Application.OnTime dNext, "refreshdata"
Workbooks(ActiveWorkbook.Name).RefreshAll
End Sub

Sub refreshdata()
dNext = TimeSerial(Hour(dNext) + 1, 20, 0)
Application.OnTime dNext, "refreshdata"
Workbooks(ActiveWorkbook.Name).RefreshAll
End Sub

Sub cancelTimer()
Application.OnTime dNext, "refreshdata", , False
End Sub
Edit/Delete Message
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Refresh data with macro code 0
Conflicting VBA Coding 7
Run Error while protected 1
Help! Combine Macros 2
Timer question 4
2 codes in one sheet 5
ontime code 4
Close help 2

Back
Top