Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default "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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default "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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autofilter set to "SHOW ALL" on open for a protected worksheet Sandra Excel Discussion (Misc queries) 10 September 18th 07 01:02 PM
Setting AutoFilter to "Show All" when worksheet is opened Bob Excel Programming 5 July 10th 07 09:34 PM
What is causing "Block if without End if" error? davegb Excel Programming 3 September 8th 05 10:29 PM
Adding "And" clause in SQL string causing SQL Syntax error Android[_2_] Excel Programming 3 July 8th 04 09:36 PM
"Can't Show Modally" - Run-Time Error '400' Problem Bruce B[_2_] Excel Programming 3 July 14th 03 02:01 PM


All times are GMT +1. The time now is 01:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"