
This approach relies on calculating an expiration date based on the initial opening, and saving the date into a hidden a named range ( ExpDate). Prefer using this approach if you want the expiration date to be set automatically when the user opens the workbook for the first time. All Excel workbooks has ThisWorkbook object by default. By the way, you do not need to create a module for this application. If you are new to VBA and macros, visit How to create a macro in Excel to a fast start.


Another workaround is to break the protection of VBA and workbook with "brute force" attacks.Īlthough, this security method isn’t enough for an experienced user, your file will be safe for most Excel users. And you need to Workbook_Open event to fire your actual macro when the workbook opens. Excel and VBA protection methods are created to prevent the users from changing a value or a formula “accidentally”.Īnyone can stop the Workbook_Open event from running by holding the Shift key when opening the workbook. In this guide, we're going to show you how to set an Excel expiration date using VBA to prevent access to the workbook after expiration.ĭownload Workbook Security of expiration dateīefore starting, we should mention that VBA-based solutions are never foolproof.

Unfortunately, Excel doesn’t have a built-in tools to handle this scenario, but you can use VBA to build this feature on your own. You may want to set an expiration date for a workbook and prevent access for when creating a trial application, or simply ensuring that the application data is up to date.
