Store Update Date in Public/Global Variable

breynolds0431

Board Regular
Joined
Feb 15, 2013
Messages
75
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

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,252
Office Version
  1. 365
Platform
  1. Windows
You will need to write the date somewhere, as all variables are lost when the workbook closes.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,252
Office Version
  1. 365
Platform
  1. Windows
You're welcome.
 

Forum statistics

Threads
1,141,072
Messages
5,704,133
Members
421,329
Latest member
mippy

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
Top