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

Posted on 2014-07-15
Last Modified: 2014-07-15
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?

Question by:gvilbis
    LVL 13

    Assisted Solution

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

    LVL 13

    Accepted Solution

    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

    LVL 8

    Assisted Solution

    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 ;(

    LVL 8

    Assisted Solution

    ooppps sorry seen post after posting.
    LVL 13

    Expert Comment

    Thanks for your points

    Have a nice day


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
    Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  ( Here (http…
    The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
    This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now