Aug 15 2021 10:03 PM
I'm working on a spreadsheet that consists of two sheets - a "Transaction Log" that contains a list of expense records. The second sheet is titled "New Summary" and is basically a "dashboard" that displayed summarized totals. The "Dashboard" includes a number of buttons - each of which executes a Macro that places a filter on the Transaction log that displays just the records associated with the "drill down" selected.
I've added a button titled "Clear Filters and Return" on the Transaction Log that fires off the following code snippet - which clears the filter - returns the user to the "New Summary" sheet. This all works exactly as I want it to EXCEPT in instances that the "Clear Filters and Return" button is selected when no filter is active on the Transaction log. Executing this block of code when no filter is in effort generates a "1004 Run Time Error".
Sub ClearAndReturn()
'ActiveSheet.ShowAllData
Sheets("New Summary").Select
End Sub
Can somebody tell me how test to determine IF a filter is in effort prior to issuing the "ActiveSheet.ShowAllData" command?
Aug 16 2021 12:33 AM
SolutionTry
If ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If
or
On Error Resume Next
ActiveSheet.ShowAllData
On Error GoTo 0
Aug 16 2021 06:42 AM
Aug 16 2021 12:33 AM
SolutionTry
If ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If
or
On Error Resume Next
ActiveSheet.ShowAllData
On Error GoTo 0