Setting back the autofilter to 'all'

V

VILLABILLA

Hi,

I have a worksheet that has the autofilter working on two columns;
and B.

It is important that when the user is done with viewing the sheet tha
he or she puts back the autofilter to 'all' so that all data i
visible, otherwise I get a mix up with macro that is in work.

This macro pastes data on the sheet, if the autofilter has sorte
something at the same moment, I get an error.

I can warn them to set back the autofilter before they leave the shee
but I already know that it is gonna be an issue because they wil
sometimes forget to do that...

Is there a way to get the autofilter to go back automatically when the
leave the worksheet?

If above asked is not possible, an alternative option would be to pu
in an error message box when the macro goes wrong that tells the use
to change back the autofilter.

I hope I'm not asking to much...

Thanks in advance
 
R

Ron de Bruin

Hi VILLABILLA

You can use this event in the sheet module maybe

Private Sub Worksheet_Deactivate()
Me.AutoFilterMode = False
End Sub
 
A

AlfD

Robby:

I suggest you don't rely on users to do the right thing.

Maybe you should do the safety job in your pasting macro: have it rese
the autofilter to what you want. (References to autofilter in Help)

Al
 
B

Bob Phillips

This might be one way to do it

On Error Resume Next
stradd = ActiveSheet.AutoFilter.Range.Address
If Err.Number = 0 Then
Range(stradd).AutoFilter
End If
On Error GoTo 0

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
D

Dave Peterson

One more way:

With ActiveSheet
If .FilterMode Then
.ShowAllData
End If
End With

or just:

on error resume next
activesheet.showalldata
 
V

VILLABILLA

I'm very impressed... first of all with all your solutions and secondl
with the enormous amount of possibilities Excel has...

Thanks a lot
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top