Browse » Home
Friday, April 12, 2013
How to Make an Excel Spreadsheet Expire
1. Open Microsoft Excel, go to the “File” menu and choose “Open.” Browse for the Excel file that you want to make expire and double-click the file name to open it.
2. Press “Alt F11” to launch the Visual Basic Editor from Excel. Use either “Ctrl R” to switch to the “Project Explorer” window or go to the “View” menu, point to “Other Windows” and choose “Project Explorer” from the list of options.
3. Right-click “ThisWorkbook” in the “Project Explorer” window. Select “View Code” from the list of available options.
4. Type the code that makes the spreadsheet expire into the code box provided. A proper code format that provides users with a message regarding the expiration date and the number of days left until the spreadsheet expires looks like this:
Sub Auto_Open()\\ Dim exdate As Date \\ exdate = \'12/01/10\' \\ If Date > exdate Then \\ MsgBox (\'Spreadsheet has Expired\') \\ ActiveWorkbook.Close \\ End If \\ MsgBox (\'Workbook Valid Until\' exdate - Date \'Days left\') \\ End Sub
Enter the date that the spreadsheet should expire by “exdate=” and any message you prefer regarding the expired worksheet in the place of “Spreadsheet has Expired.”
5. Return to the open Excel spreadsheet, go to the “File” menu and select “Save” to save the workbook with the new macro attached. Close the workbook and reopen it in Excel. The message you entered into the macro should appear, stating the expiration date of the file and how many days are left until it expires.