Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 337
Default ActiveSheet.ShowAllData

This fails at the last line "ShowAllData method of worksheet class failed" if
there is no filtering active

Private Sub CommandButton1_Click() 'Clears all filters
Range("A3").Select
ActiveSheet.ShowAllData
End Sub

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default ActiveSheet.ShowAllData

This is a commandbutton placed on a worksheet?

If yes:

with me
if .filtermode then
.showalldata
end if
end with

If it's a commandbutton on a userform, then using Activesheet makes sense.

oldjay wrote:

This fails at the last line "ShowAllData method of worksheet class failed" if
there is no filtering active

Private Sub CommandButton1_Click() 'Clears all filters
Range("A3").Select
ActiveSheet.ShowAllData
End Sub

End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default ActiveSheet.ShowAllData

Hi oldjay,

This firstly tests if filtering dropdown arrows are on then tests if a
filter is actually applied.

Private Sub CommandButton1_Click() 'Clears all filters
With ActiveSheet
If .AutoFilterMode Then
If .FilterMode Then
ActiveSheet.ShowAllData
End If
End If
End With
End Sub

--
Regards,

OssieMac


"oldjay" wrote:

This fails at the last line "ShowAllData method of worksheet class failed" if
there is no filtering active

Private Sub CommandButton1_Click() 'Clears all filters
Range("A3").Select
ActiveSheet.ShowAllData
End Sub

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default ActiveSheet.ShowAllData

You are getting the error, because there is no data being filtered. In other
words, although AutoFilter Mode is on all rows are visible. I don't normally
use the On Error Resume Next, but this case it may make sense to use it.

By the way, you don't have to select a sheet to run your code. Just
reference your sheet by name. Put the sheet name in where I have Your Sheet
Name Here or just use the code below (which is yours).

Hope this helps! If so, let me know, click "YES" below.

Private Sub CommandButton1_Click() 'Clears all filters
On Error Resume Next
Sheets("Your Sheet Name Here").ShowAllData
On Error GoTo 0
End Sub



Private Sub CommandButton1_Click() 'Clears all filters
Range("A3").Select
On Error Resume Next
ActiveSheet.ShowAllData
On Error GoTo 0
End Sub


--
Cheers,
Ryan


"oldjay" wrote:

This fails at the last line "ShowAllData method of worksheet class failed" if
there is no filtering active

Private Sub CommandButton1_Click() 'Clears all filters
Range("A3").Select
ActiveSheet.ShowAllData
End Sub

End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default ActiveSheet.ShowAllData

I figured there was a way to test if data is filtered or not. I hate using
the On Error Goto Next statement.

Private Sub CommandButton1_Click() 'Clears all filters
With Sheets("Your Sheet Name Here")
If .AutoFilterMode And .FilterMode Then .ShowAllData
End With
End Sub

--
Cheers,
Ryan


"OssieMac" wrote:

Hi oldjay,

This firstly tests if filtering dropdown arrows are on then tests if a
filter is actually applied.

Private Sub CommandButton1_Click() 'Clears all filters
With ActiveSheet
If .AutoFilterMode Then
If .FilterMode Then
ActiveSheet.ShowAllData
End If
End If
End With
End Sub

--
Regards,

OssieMac


"oldjay" wrote:

This fails at the last line "ShowAllData method of worksheet class failed" if
there is no filtering active

Private Sub CommandButton1_Click() 'Clears all filters
Range("A3").Select
ActiveSheet.ShowAllData
End Sub

End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default ActiveSheet.ShowAllData

That should have been just .ShowAllData. Don't need to repeat ActiveSheet in
the With / End With.

Private Sub CommandButton1_Click() 'Clears all filters
With ActiveSheet
If .AutoFilterMode Then
If .FilterMode Then
.ShowAllData
End If
End If
End With
End Sub

--
Regards,

OssieMac


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default ActiveSheet.ShowAllData

Thanks for your contribution Ryan. You just forced me into testing this
because for some reason I had the idea that AutoFilterMode and FilterMode
could not be used in the one line because I was sure that FilterMode produced
an error if the filter dropdowns were not visible. However, my belief was not
correct and I have now realized that the code can be simplified even more by
just testing for FilterMode.

Private Sub CommandButton1_Click() 'Clears all filters
With ActiveSheet
If .FilterMode Then .ShowAllData
End With
End Sub

Tested in xl2002 and xl2007 and it works fine.



--
Regards,

OssieMac


"Ryan H" wrote:

I figured there was a way to test if data is filtered or not. I hate using
the On Error Goto Next statement.

Private Sub CommandButton1_Click() 'Clears all filters
With Sheets("Your Sheet Name Here")
If .AutoFilterMode And .FilterMode Then .ShowAllData
End With
End Sub

--
Cheers,
Ryan


"OssieMac" wrote:

Hi oldjay,

This firstly tests if filtering dropdown arrows are on then tests if a
filter is actually applied.

Private Sub CommandButton1_Click() 'Clears all filters
With ActiveSheet
If .AutoFilterMode Then
If .FilterMode Then
ActiveSheet.ShowAllData
End If
End If
End With
End Sub

--
Regards,

OssieMac


"oldjay" wrote:

This fails at the last line "ShowAllData method of worksheet class failed" if
there is no filtering active

Private Sub CommandButton1_Click() 'Clears all filters
Range("A3").Select
ActiveSheet.ShowAllData
End Sub

End Sub

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default ActiveSheet.ShowAllData

All of these procedures remove filtering completely.
Is there a way to unfilter any particular column but leave the filter
controls at the top for future use.
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default ActiveSheet.ShowAllData

Hi Slim,

Following shows how to test if individual filter is on and how to turn off
an individual filter. (You don't have to test if on before turning off; that
is just part of my example. However, need to test for .AutoFilterMode
otherwise the code errors if AutoFilter NOTon.).


Sub FilterTest()

With Worksheets("Sheet1")
If .AutoFilterMode Then
'Test if filter 3 is applied
If .AutoFilter.Filters(3).On Then
'Turn off filter 3
.AutoFilter.Range.AutoFilter Field:=3
End If
End If
End With
End Sub


One would think that .AutoFilter.Filters(3).On = False should work but it
doesn't and I can't find any other method other than my example to turn if
off.

--
Regards,

OssieMac


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
Use a password in VBA ActiveSheet.protect & ActiveSheet.unprotect? Jim K. Excel Programming 2 June 2nd 08 08:09 PM
Troubles with ActiveSheet.ShowAllData [email protected] Excel Programming 3 June 1st 06 02:50 PM
ShowAllData Pat Excel Discussion (Misc queries) 3 April 14th 05 10:08 PM
ActiveSheet.ShowAllData shows everything - way to have hidden _not_ show up? StargateFanFromWork Excel Programming 1 July 8th 04 04:33 AM
vba-showalldata chick-racer[_45_] Excel Programming 7 December 5th 03 09:00 PM


All times are GMT +1. The time now is 10:43 PM.

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"