how do i block macro excel after 3 months in the code?

i wrote a macro in excel and i would like that after 3 months it will not be able to run any more until i will put new pass, how do i do that?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Could you do it by putting password on macro ?
take a look at this about protect macro on Excel

OR you can set expire date for the macro on VBA
the following code is reference only.

You can put it the "ThisWorkbook" in the workbook
When you open new workbook and press atl-F11, it will
show a few sheets such sheet1(Sheet1),Sheet2(Sheet2),Sheet3(Sheet3) and "ThisWorkbook".
The macra will run first in proiority in the "ThisWorkbook" when
the workbook opens
Hope undrestand your question completely.If not , please point it out.

Sub AutoOpen()
End Sub
Sub ExpirationCode()
Dim ExpirationDate As Date
ExpirationDate = DateSerial(2014, 10, 11)
If Now() >= ExpirationDate Then
MsgBox “Trial Period ended on ” & CStr(ExpirationDate) & “.”
ThisWorkbook.Close savechanges:=False
End If
End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Naresh PatelTraderCommented:
I don't write code but my logic says.
A Macro password protected as mention by Mr.Duncan
B Need a code line which match date with todays date i.e. =TODAY() if it is after prescribed date then Don't execute.

Drawback - any one can fool this by changing system date ;(

Naresh PatelTraderCommented:
ooppps sorry seen post after posting.
Thanks for your points

Have a nice day

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.