Code to turn off autofilter

F

fgwiii

I am in the process of making several macros and I was wondering if there is
code to place in the macro that can - if the autofilter is on, will turn
autofilter off just prior to copying the work sheet?

I am currently using the code in RDB_copy_sheet to copy the worksheets

Thanks
 
P

Per Jessen

Hi

Take a look at this:

Sub aaa()
If Worksheets("Sheet1").AutoFilterMode Then
isOn = "Was on"
Worksheets("Sheet1").UsedRange.AutoFilter
Else
isOn = "Off"
End If
MsgBox "AutoFilterMode is " & isOn
End Sub

Regards,
Per
 
D

Dave Peterson

With worksheets("SomeSheetNameHere")
'to remove the filter and the arrows
.AutoFilterMode = False

'or to just show all the data and keep the arrows
If .FilterMode Then
.ShowAllData
End If
End With


Or you could ignore errors, too:

on error resume next
ActiveSheet.ShowAllData 'keeps the arrows, shows all the data.
 

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