Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Expiration Date for Excel Programs.

Expiration Date for Excel Programs

Written by Allen Wyatt (last updated February 12, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


1

Excel provides a robust development environment of which many people take full advantage. In fact, many people have written entire application programs using VBA with Excel as the framework.

If you do program development in Excel, you may be wondering if there is a way to write your program so that it will no longer work after a specific date. Fortunately, this is rather easy. One solution is to use something like the following as an Auto_Open macro:

Sub Auto_Open()
    Dim exdate As Date
    exdate = "12/31/2022"
    If Date > exdate Then
        MsgBox ("You have reached end of your trial period")
        ActiveWorkbook.Close
    End If
    MsgBox ("You have " & exdate - Date & "Days left")
End Sub

If the date on the system running the program is greater than the date specified in the exdate variable, the user will see a message box indicating that their trial period has expired. When the user clicks on the OK button, the workbook closes. If the trial period is not over, then the message box indicates how many days are left in the period.

Of course, if you put a macro such as this in your application, it may stop you from opening the workbook to make program changes. The obvious way around this, of course, is to hold down the Shift key as you open the workbook. Doing so stops the Auto_Open macro from running. If your users know this, they can bypass the expiration check just as easily as you, however. The solution is to place similar checks within other macros that cannot be bypassed and that are essential to your program.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10230) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Expiration Date for Excel Programs.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Getting Help in Dialog Boxes

Dialog boxes are prevalent in a program like Word, and they can contain dozens (if not hundreds) of options. This tip ...

Discover More

Turning On Property Information Prompting

You may want to make sure that users of a document fill in the properties associated with a document. In most versions of ...

Discover More

Assigning a Macro to a Shortcut Key

Do you have a macro that you use frequently? Using the File menu to access the macro can be time consuming. This tip ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Enforcing Moving Cells Up

When you design your worksheets, you probably want users to interact with those worksheets in specific ways. What ...

Discover More

Showing RGB Colors in a Cell

Excel allows you to specify the RGB (red, green, and blue) value for any color used in a cell. Here's a quick way to see ...

Discover More

Deleting Worksheet Code in a Macro

When creating an application in VBA for others to use, you might want a way for your VBA code to modify or delete other ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is one less than 9?

2022-02-14 03:57:03

Philip

In this context I’ve been trying to find information about how to consult a table (Excel or SQL) residing on an FTP server from a VBA routine. The purpose would be to check from the VBA built application if the license code in the app is still valid based on an online table I maintain.

I haven’t been able to come across any comprehensive information … anyone knows which steps to take to make this happen (on the FTP-side as well as in the VBA module) ? This needs to work on both Windows and Mac …


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.