ManuGrim
New Member
Hello,
I have a worksheet with 4 buttons assigned to 4 macros.
I press the button and the macro runs.
But now I want to call these macros according to a cell value.
If A1 = Daily then run macro 1
If A1 = Weekly then run macro 2
etc.
What is the code in the respective sheet for calling a macro from a module?
The code and the macros:
Thank you!
I have a worksheet with 4 buttons assigned to 4 macros.
I press the button and the macro runs.
But now I want to call these macros according to a cell value.
If A1 = Daily then run macro 1
If A1 = Weekly then run macro 2
etc.
What is the code in the respective sheet for calling a macro from a module?
The code and the macros:
Code:
Private Sub RunFilter(rng As Range, IsUnique As Boolean)
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
rng.AdvancedFilter Action:=xlFilterInPlace, Unique:=IsUnique
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
End With
End Sub
Sub Daily()
Call RunFilter(Range("A1:A1000"), False)
End Sub
Sub Weekly()
Call RunFilter(Range("B6:B371"), True)
Call RunFilter(Range("B371:B736"), True)
Call RunFilter(Range("B736:B1102"), True)
End Sub
Sub Monthly()
Call RunFilter(Range("C6:C371"), True)
Call RunFilter(Range("C371:C736"), True)
Call RunFilter(Range("C736:C1102"), True)
End Sub
Sub Quarterly()
Call RunFilter(Range("D6:D371"), True)
Call RunFilter(Range("D371:D736"), True)
Call RunFilter(Range("D736:D1102"), True)
End Sub
Thank you!