Hi,
I'd like to apologize in advance if the following question seems rudimentary as I'm very new to VBA. However, i've written a macro that basically just pastes a row as values for every sheet in my workbook.
I would like for this to run automatically at 6 specific times throughout the day: 700, 900, 1100,1130,1400,1430. Mon-Fri only.
In doing research, i know im supposed to use the Application.Ontime functionality however, i've been unable to get this to run correctly.
Any help would be greatly appreciated. Here is my code:
I've tried the following without any luck:
screenshot of my VBA: https://imgur.com/a/9T1M9So
I'd like to apologize in advance if the following question seems rudimentary as I'm very new to VBA. However, i've written a macro that basically just pastes a row as values for every sheet in my workbook.
I would like for this to run automatically at 6 specific times throughout the day: 700, 900, 1100,1130,1400,1430. Mon-Fri only.
In doing research, i know im supposed to use the Application.Ontime functionality however, i've been unable to get this to run correctly.
Any help would be greatly appreciated. Here is my code:
Code:
<code class="s1s4008e-7 hGYywx">Sub PopulateData()
Dim WS_Count As Integer
Dim I As Integer
WS_Count = ActiveWorkbook.Worksheets.Count
Application.DisplayAlerts = False
Application.ScreenUpdating = False
For I = 1 To WS_Count
Sheets("Crude").Range("Date_Time2").Copy
ActiveWorkbook.Worksheets(I).Activate
Cells.Find(What:="Date", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).End(xlDown).Offset(1, 0).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range(Selection, Selection.End(xlToRight)).Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Next I
ActiveWorkbook.Worksheets("Crude").Activate
ActiveWorkbook.Save
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub</code>
I've tried the following without any luck:
Code:
<code class="s1s4008e-7 hGYywx">Private Sub Workbook_Open()
Application.OnTime TimeValue("07:00:00"), "PopulateData"
Application.OnTime TimeValue("09:00:00"), "PopulateData"
Application.OnTime TimeValue("11:00:00"), "PopulateData"
Application.OnTime TimeValue("11:30:00"), "PopulateData"
Application.OnTime TimeValue("14:00:00"), "PopulateData"
Application.OnTime TimeValue("14:30:00"), "PopulateData"
End Sub</code>
screenshot of my VBA: https://imgur.com/a/9T1M9So