Assign Expiry Date to Macro

How to assign an expiry date to a macro. Watch the video below:

Assign Expiry Date to Macro

Here’s the complete VBA code to make a macro expire by a specific date:

Sub CalculateTax()
Dim ExpiryDate As Date
ExpiryDate = #4/28/2022#
If Now() < ExpiryDate Then
Dim i As Long, lastrow As Long
lastrow = Application.WorksheetFunction.CountA(Sheet1.Range(“A:A”))
MsgBox “The last row used is ” & lastrow
For i = 2 To lastrow
Cells(i, 4) = Cells(i, 3) * Cells(i, 2)
Cells(i, 5) = Cells(i, 4) * 0.12
Next i
End If
End Sub

The above macro was used in the last macro while creating a floating button.

Now we have added an ‘IF’ condition that checks for a date. If the current date on the PC is prior to April 28 2022 then the macro executes. If it is April 28 2022 or later, the macro will stop working!

Assign Expiry Date to Macro – If it is April 28 2022 or later, the macro will stop working!