Store Update Date in Public/Global Variable

breynolds0431

Active Member
Joined
Feb 15, 2013
Messages
303
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hello. I have current code that will write a date to a worksheet after the code has successfully run. The code just updates sheet data from a report, which isn't relevant to this question. However, the reason the code writes the update date to the sheet is so that it can be used in a workbook_open event to check if that date is more than 7 days old. If it is, a message box will display stating how many days old the report data is and reminds the user to run another update. The update requires an external report to be run, so we can't automate this to run the update code automatically if it's been more than 7 days. The current process is working fine, but I was just wondering if the date actually needs to be written to a sheet? There are possibly some risks associated with doing that, such as the sheet being deleted or the range cleared. Could the update date be stored as a public or global variable and used in the workbook_open to check how many days it's been since the last update? I'm not really sure how public variables work or if a module code could write a public variable that a workbook open code could utilize. Thanks for reading this and your thoughts.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You will need to write the date somewhere, as all variables are lost when the workbook closes.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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