Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Need macro to turn off AutoFilters in a table (repost)

I have data in an Excel 2007 table called "table2". I have a macro that
turns on the AutoFilters drop-down arrows in the table. It works fine in
Excel 2003 and 2007.

I have another macro that in Excel 2003 works fine to turn off the
AutoFilters in the table, but it doesn't work for Excel 2007. The macro that
works for Excel 2003 is:

Sub RemoveAutoFilters()
If ActiveSheet.AutoFilterMode = True Then
ActiveSheet.AutoFilterMode = False
End If
End Sub

What am I doing wrong that it won't work in Excel 2007? I have Bing/Googled
it but can't find the answer. Thank you!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Need macro to turn off AutoFilters in a table (repost)

To remove the filters, you can do this

ActiveSheet.ShowAllData

You can still reapply the filters later.

--
HTH,

Barb Reinhardt



"Jeremy" wrote:

I have data in an Excel 2007 table called "table2". I have a macro that
turns on the AutoFilters drop-down arrows in the table. It works fine in
Excel 2003 and 2007.

I have another macro that in Excel 2003 works fine to turn off the
AutoFilters in the table, but it doesn't work for Excel 2007. The macro that
works for Excel 2003 is:

Sub RemoveAutoFilters()
If ActiveSheet.AutoFilterMode = True Then
ActiveSheet.AutoFilterMode = False
End If
End Sub

What am I doing wrong that it won't work in Excel 2007? I have Bing/Googled
it but can't find the answer. Thank you!

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Need macro to turn off AutoFilters in a table (repost)

Hi Jeremy,

You need to reference the table in the worksheet not just the worksheet.
The "If/End If " is not required if you simply want to ensure AutoFilter is
Off.

Example 1:
Sub TablesAndAutoFilter()

Dim ws As Worksheet
Dim objList As ListObject

Set ws = ActiveWorkbook.Worksheets("Sheet1")

Set objList = ws.ListObjects("Table2")

If objList.ShowAutoFilter Then 'Omitt if simply turning off
objList.ShowAutoFilter = False
End If 'Omitt if simply turning off

End Sub


Example 2:
Without assigning to variables and simply ensuring that autofilter is off.

ActiveWorkbook.Worksheets("Sheet1") _
.ListObjects("Table2") _
.ShowAutoFilter = False

--
Regards,

OssieMac


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Need macro to turn off AutoFilters in a table (repost)

Hi Jeremy...

assuming your table starts at range = A1 a VERY simple script is..

Sub RemoveAutoFilters()

Range("A1").Select
Selection.AutoFilter

end sub

This code merely "switches" autofilter on if it is off or off if it is on...
If mutliple tables, then merely use the same script pointing to the various
ranges

"Jeremy" wrote:

I have data in an Excel 2007 table called "table2". I have a macro that
turns on the AutoFilters drop-down arrows in the table. It works fine in
Excel 2003 and 2007.

I have another macro that in Excel 2003 works fine to turn off the
AutoFilters in the table, but it doesn't work for Excel 2007. The macro that
works for Excel 2003 is:

Sub RemoveAutoFilters()
If ActiveSheet.AutoFilterMode = True Then
ActiveSheet.AutoFilterMode = False
End If
End Sub

What am I doing wrong that it won't work in Excel 2007? I have Bing/Googled
it but can't find the answer. Thank you!

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Need macro to turn off AutoFilters in a table (repost)

ActiveSheet.ShowAllData is working in a Table

See also
http://msdn.microsoft.com/en-us/libr...ffice.11).aspx

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Jeremy" wrote in message ...
I have data in an Excel 2007 table called "table2". I have a macro that
turns on the AutoFilters drop-down arrows in the table. It works fine in
Excel 2003 and 2007.

I have another macro that in Excel 2003 works fine to turn off the
AutoFilters in the table, but it doesn't work for Excel 2007. The macro that
works for Excel 2003 is:

Sub RemoveAutoFilters()
If ActiveSheet.AutoFilterMode = True Then
ActiveSheet.AutoFilterMode = False
End If
End Sub

What am I doing wrong that it won't work in Excel 2007? I have Bing/Googled
it but can't find the answer. Thank you!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Many thanks OssieMac

Many thanks OssieMac. It works perfectly.
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
Need Excel macro to turn off AutoFormat in a table Jeremy Excel Programming 2 November 16th 09 06:53 AM
macro to turn pivot table field on and off S Himmelrich Excel Programming 1 January 21st 09 08:51 PM
Turn AutoFilters Off Jasmine Excel Programming 11 December 21st 05 05:37 PM
Autofilters in a Pivot table Kymezo Excel Worksheet Functions 0 February 17th 05 09:01 PM
Userforms and autofilters - Autofilters don't seen to work with userform No Name Excel Programming 3 August 28th 03 05:42 PM


All times are GMT +1. The time now is 12:34 AM.

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

About Us

"It's about Microsoft Excel"