View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Shawn Shawn is offline
external usenet poster
 
Posts: 271
Default Code to unfilter if filtered

The code below works. It selects a filtered range and unfilters it.

Dim WSNames As Worksheet
Dim rng As Range
Set WSNames = Sheets("Names")
Set rng = WSNames.Range(WSNames.Range("A1"),
WSNames.Range("C1").End(xlDown))

WSNames.Select
rng.Select
ActiveSheet.ShowAllData


However, occassionally the data is not filtered at all. If the data is in
autofiltermode but nothing is filtered then it gives me an error at the
"ActiveSheet.ShowAllData" line.

I guess I need an If Then that will correct this???


--
Thanks
Shawn