ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   code for program run once everyday (https://www.excelbanter.com/excel-programming/336102-code-program-run-once-everyday.html)

Angus

code for program run once everyday
 
What is the code if I want it runs only once per day?

Rowan[_2_]

code for program run once everyday
 
If you mean set a macro to run at a scheduled time then see

http://www.cpearson.com/excel/ontime.htm

otherwise if you mean only allow a macro to be run only once per day then
you could have a hidden sheet (Sheet1 in my example) with a date in cell A1.
Then you could code your macro like this:

Sub RunIt()
If Sheets("Sheet1").Range("A1").Value = Date Then
MsgBox "Macro has been run already today.", vbExclamation
Else
Sheets("Sheet1").Range("A1").Value = Date
'rest of code here
End If
End Sub

This checks the date on the hidden sheet and if it is not the current date
it sets it to today and then runs rest of code. If the date on the sheet is
already today then it gives a message saying the macro has already been run.

Hope this helps
Rowan

"Angus" wrote:

What is the code if I want it runs only once per day?


Patrick Molloy[_2_]

code for program run once everyday
 
Application.OnTime "08:00","MyProc"
read HELP for more

"Angus" wrote:

What is the code if I want it runs only once per day?



All times are GMT +1. The time now is 02:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com