Macro expires

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
works great thanks!

Ron de Bruin said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top