Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Code to unfilter if filtered

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
if ActiveSheet.FilterMode then
ActiveSheet.ShowAllData
End if

--
Regards,
Tom Ogilvy


"Shawn" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
unfilter peyman Excel Discussion (Misc queries) 2 October 26th 07 05:45 PM
Filtered rows not in code??? John Excel Programming 5 November 16th 06 07:59 PM
excel should let me unfilter all columns with one click B Excel Programming 2 September 7th 06 12:59 PM
Code to unfilter one field only scrabtree23[_3_] Excel Programming 2 November 19th 05 04:03 PM
Unfilter JohnUK Excel Programming 2 June 18th 04 04:33 PM


All times are GMT +1. The time now is 09:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"