ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro triggered by date (https://www.excelbanter.com/excel-programming/433423-re-macro-triggered-date.html)

ker_01

Macro triggered by date
 
In addition to the other answers;

If this is a workbook you are in all the time anyway, then having the timer
in the workbook is fine.

I have one workbook that is only opened when data needs to be crunched, and
that data is only available for a limited time period, so it needs to be run
right away (and not wait for the user to remember that this is the day the
data is updated). So I set the following code in a vbs file. I then created a
windows scheduled task (in XP, Start/All Programs/Accessories/System
Tools/Scheduled Tasks). When the scheduled time occurs, the user gets the
prompt and can decide whether to open/run the file.

Of course, the update prompt is limited to the one PC this is installed on,
but I only have one user who needs to update this file, so that is fine for
our project.

strUserIn = MsgBox("Run the PO file?",vbYesNo,"Automated Prompt")
If strUserIn = 6 then
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\Documents and
Settings\Max4p\Desktop\product analysis\opo5.xls")
objExcel.Visible = True
objExcel.Run "CrunchIt", "SkipEmailPrompt"
'above line runs the macro, with optional parameter
objExcel.ActiveWorkbook.Save
end if


"Risky Dave" wrote:

Hi,

I am trying to figure out how to get a macro to run every financial quarter.

The theory should be simple - have a cell somewhere that captures the last
time the macro was run (in mmm-yy format) and add 3 months. compare that
value with TODAY() and if TODAY() is greater, run the macro.

The problem I have (and I'm sure it's easy to fix I just can't figure it
out) is how to define teh last run date plus 3 months. I can't do a day count
due to the differing lengths of months and I don't know how to tell Excel to
count months.

Any help you can supply would be appreciated.

Hope this makes sense!

TIA

Dave



All times are GMT +1. The time now is 05:17 PM.

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