• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 411
  • Last Modified:

Turn off any filter onopen of workbook

I am trying to turn off any filter that was left on close of the workbook when I reopen the book.

onopen I have this
   Set OTEws = Worksheets("OTE's")

    'unfilter the sheet
    OTEws.AutoFilterMode = False
    OTEws.FilterMode = False
    OTEws.ShowAllData = True

I keep getting errors.  What is the best way to unfilter the sheet so I can get a total row count.

thanks xperts
0
skillilea
Asked:
skillilea
1 Solution
 
krishnakrkcCommented:
Hi,

On Error Resume Next
OTEws.AutoFilterMode = False
OTEws.ShowAllData

Kris
0
 
dandrakaCommented:
Try this code:
Sub xxxx()
Dim w As Worksheet
Set w = Application.ActiveSheet
'For AutoFilter
If w.AutoFilterMode = True Then w.AutoFilterMode = False
'For other filter
If w.FilterMode = True Then w.ShowAllData
End Sub

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now