Written by Allen Wyatt (last updated February 12, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365
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:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10230) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Expiration Date for Excel Programs.
Dive Deep into Macros! Make Excel do things you thought were impossible, discover techniques you won't find anywhere else, and create powerful automated reports. Bill Jelen and Tracy Syrstad help you instantly visualize information to make it actionable. You’ll find step-by-step instructions, real-world case studies, and 50 workbooks packed with examples and solutions. Check out Microsoft Excel 2019 VBA and Macros today!
Creating lot of copies of a worksheet is a snap within a macro. This tip introduces a macro that will make three copies ...
Discover MoreDoes your macro need to get some input from a user? Here are the ways that Excel provides for that input to be solicited.
Discover MoreRenaming a worksheet within a macro is a relatively easy task. When you start renaming based on a range of names, though, ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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 …
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments