willow1985
Well-known Member
- Joined
- Jul 24, 2019
- Messages
- 929
- Office Version
- 365
- Platform
- Windows
I have a few Macros that I would like to make expire monthly to allow for maintenance. I would like to add an Expire Macro and then have this called. That way when I have to update the date I only have to update the Expire Macro and not every Macro that calls it. However I cannot get the Expire Macro to actually stop running the Macro it is called inside (I am not sure how to explain this)
Here is a snip of one of the Macros I want to expire:
And Here is the Expire Macro:
Whether a correct password is entered or it is cancelled I want the Expire Macro to end Macro1 as well, but this does not seem to be happening and Macro1 runs anyway even if it is expired/wrong password or no password is entered/cancelled.
I have tried using End instead of Exit Sub but this also does not work.
Help with this would be greatly appreciated
Here is a snip of one of the Macros I want to expire:
VBA Code:
Sub Macro1()
'
' Macro1
Call Expire
Application.ScreenUpdating = False
'Clear all filters and prepare tables for data
Sheets("WO Report").Select
Dim lo As ListObject
For Each lo In ActiveSheet.ListObjects
lo.AutoFilter.ShowAllData
Next lo
If (ActiveSheet.AutoFilterMode And ActiveSheet.FilterMode) Or ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If
Worksheets("WO Report").Rows(2 & ":" & Worksheets("WO Report").Rows.Count).EntireRow.Delete
Range("A2").Select
Sheets("Inv Report").Select
And Here is the Expire Macro:
VBA Code:
Const sPassword = "Password"
Dim sUserInput
If Date > CDate("06/09/2024") Then
sUserInput = InputBox("Enter password to continue...", "Enter Password")
If Not sUserInput = sPassword Then
MsgBox "Wrong password, Macro has expired"
Exit Sub
End If
End If
End Sub
Whether a correct password is entered or it is cancelled I want the Expire Macro to end Macro1 as well, but this does not seem to be happening and Macro1 runs anyway even if it is expired/wrong password or no password is entered/cancelled.
I have tried using End instead of Exit Sub but this also does not work.
Help with this would be greatly appreciated