Phoenix333
New Member
- Joined
- Sep 28, 2010
- Messages
- 26
I have a scheduled event to open a workbook at a set time each day. In the workbook, I have a macro programmed to run on opening [Autpen]. The last part of the macro saves then also does a save as, adds today's date to the filename and removes the macro so the new worksheet can be opened and viewed by others while leaving my template intact.
The problem is, I have occasion to open the template and when I do, I have to escape out of the macro to prevent it from running. Not a huge deal, but annoying.
So I thought of putting in code prior to calling the different steps of the macro that will check the value of a cell and if the value is equal to the result of the formula "=today()" then don't run the macro, but if it's not, then run it.
It's not working and since I'm not a macro expert (I get most of the code I use online and modify it to meet my needs), I'd really love some help.
Here's the code I currently have:
If ActiveSheet.Range("W2").Value = "=Today()" _
Then Exit Sub Else...
Part of the macro that runs adds the formula =today() to cell W2, then performs a copy--paste special so it doesn't change from day to day.
I want the beginning of the macro to look at the value in W2 and if the value is equal to what =today() would be, then I don't want the macro to run. So, for example, the report already ran today, meaning the value in W2 is 5/13/2011. If I open the report again today, then the macro wouldn't run because the value matches today's date.
Let me know if anyone has any suggestions.
Thanks in advance for any assistance.
The problem is, I have occasion to open the template and when I do, I have to escape out of the macro to prevent it from running. Not a huge deal, but annoying.
So I thought of putting in code prior to calling the different steps of the macro that will check the value of a cell and if the value is equal to the result of the formula "=today()" then don't run the macro, but if it's not, then run it.
It's not working and since I'm not a macro expert (I get most of the code I use online and modify it to meet my needs), I'd really love some help.
Here's the code I currently have:
If ActiveSheet.Range("W2").Value = "=Today()" _
Then Exit Sub Else...
Part of the macro that runs adds the formula =today() to cell W2, then performs a copy--paste special so it doesn't change from day to day.
I want the beginning of the macro to look at the value in W2 and if the value is equal to what =today() would be, then I don't want the macro to run. So, for example, the report already ran today, meaning the value in W2 is 5/13/2011. If I open the report again today, then the macro wouldn't run because the value matches today's date.
Let me know if anyone has any suggestions.
Thanks in advance for any assistance.