Hi I'm fairly new to this forum and not too skillful with VBA. I'm writing a program that pulls data off the web and refreshes the data every 10 seconds independently. The code in bold is responsible for re-running the program and thereby refreshing the data. It is written to re-run every 10 seconds:
alertTime = Now + TimeValue("00:00:10")
Application.OnTime alertTime, "GetNewData"
The program does successfully run the first time; however, the program does not re-run again like it's supposed to and instead I get this error:
"Cannot run the macro ''C:\....\Desktop\baseball power rankings.xlsm'!GetNewData' . The macro may not be available in this workbook or all workbooks may be disabled."
Any help would be much appreciated!
Sub GetNewData()
RefreshSheets "PowerRankings"
RefreshSheets "Standings"
alertTime = Now + TimeValue("00:00:10")
Application.OnTime alertTime, "GetNewData"
End Sub
Sub RefreshSheets(SheetName As String)
With Sheets(SheetName)
.Activate
.Cells(1, 1).Select
Selection.QueryTable.Refresh BackgroundQuery:=False
End With
End Sub
Bookmarks