How to assign an expiry date to a macro. Watch the video below:
Here’s the complete VBA code to make a macro expire by a specific date:
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
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!