Refresh Morningstar Data at Specific Time

A10hammond

New Member
Joined
May 8, 2019
Messages
4
I am working to refresh morningstar data in an excel 2016 file, and I found the following code online on the Morningstar VBA guide:

Code:
Public dTime As Date
Dim lNum As Long
Sub RunOnTime()
dTime = Sheet1.Cells(1, 1) 'change the cell reference here (Row #, Column #)
Application.OnTime dTime, "RunOnTime"
Set cmd = Application.CommandBars("Cell").Controls("Refresh All")
cmd.Execute
End Sub

The guide says that this will refresh the data at 10:01:00 AM everyday, what do I change do make this refresh at 9:00 AM everyday? Also, if it refreshes everything does the cell reference matter?

Thanks.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
The time that the macro will run is determined by this line
Code:
dTime = Sheet1.Cells(1, 1)

ie currently set to the value in cell A1 in the FIRST sheet in the workbook
Enter value 09:00 in that cell to make it run at that time

Using more intuitive notation ...with time value in cell D2 in sheet named Data ...
Code:
dTime = Sheets("[COLOR=#ff0000]Data[/COLOR]").Range("[COLOR=#ff0000]D2[/COLOR]")

Excel 2016 (Windows) 32 bit
[Table="width:, class:head"][tr=bgcolor:#E0E0F0][th] [/th][th]
A
[/th][th]
B
[/th][th]
C
[/th][th]
D
[/th][th]
E
[/th][/tr]
[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
1
[/td][td] [/td][td] [/td][td] [/td][td] [/td][td] [/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
2
[/td][td] [/td][td] [/td][td] [/td][td]
09:00​
[/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
3
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]
[/table]
[Table="width:, class:grid"][tr][td]Sheet: Data[/td][/tr][/table]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top