ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro expires (https://www.excelbanter.com/excel-programming/313288-macro-expires.html)

Louise

Macro expires
 
Hello
I have a simple OnSave macro that that i have created. In cell b3 is the
date (mm/dd/yy). I would like for the onsave macro not to run if the mpnth
is later than that in b3. In other words after the last day of the month the
macro no longer runs. What code should I add to accomplish this?
Thanks
Louise

Ron de Bruin

Macro expires
 
Hi Louise

One way is to use this function in a cell ( I use C3)
to get the last day of the month

=DATE(YEAR(B3),MONTH(B3)+1,0)

And in the macro use this (first line)

If Now Sheets("Sheet1").Range("C3").Value Then Exit Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Louise" wrote in message ...
Hello
I have a simple OnSave macro that that i have created. In cell b3 is the
date (mm/dd/yy). I would like for the onsave macro not to run if the mpnth
is later than that in b3. In other words after the last day of the month the
macro no longer runs. What code should I add to accomplish this?
Thanks
Louise




Louise

Macro expires
 
works great thanks!

"Ron de Bruin" wrote:

Hi Louise

One way is to use this function in a cell ( I use C3)
to get the last day of the month

=DATE(YEAR(B3),MONTH(B3)+1,0)

And in the macro use this (first line)

If Now Sheets("Sheet1").Range("C3").Value Then Exit Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Louise" wrote in message ...
Hello
I have a simple OnSave macro that that i have created. In cell b3 is the
date (mm/dd/yy). I would like for the onsave macro not to run if the mpnth
is later than that in b3. In other words after the last day of the month the
macro no longer runs. What code should I add to accomplish this?
Thanks
Louise






All times are GMT +1. The time now is 03:53 PM.

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