Sorry about the title.
I have an excel workbook that I want to update daily so I created the following code. I also created a task so that it will update off peak hours which is great. The workbook will open, refresh, save, and close without having me to do anything.
The issue I can see with this is when I want to manually open the workbook, it's going to run this code when I don't want it to. I only want this to run with the scheduled task and now when it's manually opened. I thought about putting in a message box but then the task scheduler won't get past it.
How can I make sure the workbook is updated automatically with task scheduler, but not updated when I open the workbook manually?
Sub RefreshAndClose_Open()
ThisWorkbook.RefreshAll
DoEvents
ThisWorkbook.Save
DoEvents
Application.Quit
End Sub
IF NOW ~ 1 AM THEN EXECUTE