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 Excel macro to turn off AutoFormat in a table

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: 9
Default Need Excel macro to turn off AutoFormat in a table

Sorry the title is wrong - I meant Excel macro to turm of AutoFilter in a
table. I will repost.

"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!


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

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 'Omitted if simply turning off
objList.ShowAutoFilter = False
End If 'Omitted 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


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
macro to turn pivot table field on and off S Himmelrich Excel Programming 1 January 21st 09 08:51 PM
How do I turn off the autoformat that converts 1-0 to Jan-00? Josh Excel Discussion (Misc queries) 3 June 3rd 06 01:45 PM
Can I "customize" an autoformat report for a Pivot Table in Excel Nancy Excel Discussion (Misc queries) 1 April 6th 06 01:58 AM
How do I turn off autoformat for .CSV (comma delimited) files? Mike Schwartz Excel Discussion (Misc queries) 1 February 2nd 06 09:08 PM
How do I turn off ALL autoformat in Excel ? (I can't even type "J. Dave a.k.a. Technophobe Excel Worksheet Functions 2 February 23rd 05 01:46 AM


All times are GMT +1. The time now is 11:07 PM.

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"