PC Review


Reply
Thread Tools Rate Thread

"Autofilter: Show All" causing an error

 
 
leimst
Guest
Posts: n/a
 
      10th Oct 2008
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 With Quote
 
 
 
 
Richard Schollar
Guest
Posts: n/a
 
      10th Oct 2008
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" <(E-Mail Removed)> wrote in message
news:C3HHk.15941$(E-Mail Removed)...
> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mime Format causing "operation failed" error on opening .msg e-mai Gee Microsoft Outlook Discussion 0 11th Jul 2008 08:57 AM
Autofilter set to "SHOW ALL" on open for a protected worksheet =?Utf-8?B?U2FuZHJh?= Microsoft Excel Misc 10 18th Sep 2007 01:02 PM
Setting AutoFilter to "Show All" when worksheet is opened =?Utf-8?B?Qm9i?= Microsoft Excel Programming 5 10th Jul 2007 09:34 PM
What's causing ADO error: "Concurrency violation: the DeleteCommand affected 0 records" sherifffruitfly Microsoft ADO .NET 3 2nd Nov 2006 12:39 AM
What's causing ADO error: "Concurrency violation: the DeleteCommand affected 0 records" sherifffruitfly Microsoft C# .NET 0 31st Oct 2006 09:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:46 AM.