Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Autofilter: Show All" causing an error
Good Morning,
I recorded a macro which applies an Autofilter but in recording the macro, I selected the "Show All" filter before setting any filters so that if a filter was already being used I wouldn't being filtering data that was already filtered on another criteria. But I found that if no filters were selected at the time I ran my macro, then having the macro try to select "Show All" when no filters were being used causes an error. Does anyone know how to get around this? Thanks in advance for any help! Brian |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Autofilter: Show All" causing an error
Hi Brian
You could use On Error Resume Next to ignore this runtime error, but I would just be tempted to use: With Sheets("YourSheetName") 'amend as required .AutofilterMode = False With .Range("A1:G100") 'amend as required .Autofilter .Autofilter Field:=1, Criteria1:="YourCriteria" 'amend as required End With End With You specifically turn off Autofilter first with this method before reapplying it. It won't fail whether or not filters are applied. Richard "leimst" wrote in message ... Good Morning, I recorded a macro which applies an Autofilter but in recording the macro, I selected the "Show All" filter before setting any filters so that if a filter was already being used I wouldn't being filtering data that was already filtered on another criteria. But I found that if no filters were selected at the time I ran my macro, then having the macro try to select "Show All" when no filters were being used causes an error. Does anyone know how to get around this? Thanks in advance for any help! Brian |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Autofilter set to "SHOW ALL" on open for a protected worksheet | Excel Discussion (Misc queries) | |||
Setting AutoFilter to "Show All" when worksheet is opened | Excel Programming | |||
What is causing "Block if without End if" error? | Excel Programming | |||
Adding "And" clause in SQL string causing SQL Syntax error | Excel Programming | |||
"Can't Show Modally" - Run-Time Error '400' Problem | Excel Programming |