Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Programmatically removing data filters

I have a spreadsheet that, using VBA macros, I add rows to the end of the
table, based upon data in a database. HOwever, I have found that, if, for
whatever reason, I have a filter set on one or more columns at the time I
attempt the update, I get an error in the VBA code. My work around is to
simply ensure I have no filters set, before I run the code, but it would be
great if I could programmatically "unset" all filters on all columns, before
I do the row add activity.

Is there a quick/dirty way to do that?

thanks!

Patk
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Programmatically removing data filters

Try

If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False

Mike

"PatK" wrote:

I have a spreadsheet that, using VBA macros, I add rows to the end of the
table, based upon data in a database. HOwever, I have found that, if, for
whatever reason, I have a filter set on one or more columns at the time I
attempt the update, I get an error in the VBA code. My work around is to
simply ensure I have no filters set, before I run the code, but it would be
great if I could programmatically "unset" all filters on all columns, before
I do the row add activity.

Is there a quick/dirty way to do that?

thanks!

Patk

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Programmatically removing data filters

apologies that will remove the filter and I think you want to reset it to
all. Try this

With ActiveSheet
If .AutoFilterMode Then
.ShowAllData
End If
End With

Mike

"Mike H" wrote:

Try

If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False

Mike

"PatK" wrote:

I have a spreadsheet that, using VBA macros, I add rows to the end of the
table, based upon data in a database. HOwever, I have found that, if, for
whatever reason, I have a filter set on one or more columns at the time I
attempt the update, I get an error in the VBA code. My work around is to
simply ensure I have no filters set, before I run the code, but it would be
great if I could programmatically "unset" all filters on all columns, before
I do the row add activity.

Is there a quick/dirty way to do that?

thanks!

Patk

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Programmatically removing data filters

I'll get it right in a minute

With ActiveSheet
On Error Resume Next
If .AutoFilterMode = True Then
.ShowAllData
End If
End With

Mike

"Mike H" wrote:

apologies that will remove the filter and I think you want to reset it to
all. Try this

With ActiveSheet
If .AutoFilterMode Then
.ShowAllData
End If
End With

Mike

"Mike H" wrote:

Try

If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False

Mike

"PatK" wrote:

I have a spreadsheet that, using VBA macros, I add rows to the end of the
table, based upon data in a database. HOwever, I have found that, if, for
whatever reason, I have a filter set on one or more columns at the time I
attempt the update, I get an error in the VBA code. My work around is to
simply ensure I have no filters set, before I run the code, but it would be
great if I could programmatically "unset" all filters on all columns, before
I do the row add activity.

Is there a quick/dirty way to do that?

thanks!

Patk

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Programmatically removing data filters

That sure seemed logical enough, but it is not working. Here is the code and
note that, while I have the sheet I wanted, active, and it clearly has a
filters set, and one of the columns filtered, the debug is not triggering (so
assume the showalldata wont' work, either). I also tried naming the sheet as
Dave noted..same result. What am I missing? I do have a popup menu open
that they use to "trigger" the event, but that should not be considered a
worksheet. I even tried executing it simlply from VB, to bypass the menu,
but no joy. Ideas? Thanks for all your help!

Patk

Sub ClearFilters()
With ActiveSheet
On Error Resume Next
If .AutoFilterMode = True Then
Debug.Print "autofilter on detected"
.ShowAllData
End If
End With

End Sub



"Mike H" wrote:

I'll get it right in a minute

With ActiveSheet
On Error Resume Next
If .AutoFilterMode = True Then
.ShowAllData
End If
End With

Mike

"Mike H" wrote:

apologies that will remove the filter and I think you want to reset it to
all. Try this

With ActiveSheet
If .AutoFilterMode Then
.ShowAllData
End If
End With

Mike

"Mike H" wrote:

Try

If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False

Mike

"PatK" wrote:

I have a spreadsheet that, using VBA macros, I add rows to the end of the
table, based upon data in a database. HOwever, I have found that, if, for
whatever reason, I have a filter set on one or more columns at the time I
attempt the update, I get an error in the VBA code. My work around is to
simply ensure I have no filters set, before I run the code, but it would be
great if I could programmatically "unset" all filters on all columns, before
I do the row add activity.

Is there a quick/dirty way to do that?

thanks!

Patk



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Programmatically removing data filters

It works for me.

Do you have macros enabled?

Mike

"PatK" wrote:

That sure seemed logical enough, but it is not working. Here is the code and
note that, while I have the sheet I wanted, active, and it clearly has a
filters set, and one of the columns filtered, the debug is not triggering (so
assume the showalldata wont' work, either). I also tried naming the sheet as
Dave noted..same result. What am I missing? I do have a popup menu open
that they use to "trigger" the event, but that should not be considered a
worksheet. I even tried executing it simlply from VB, to bypass the menu,
but no joy. Ideas? Thanks for all your help!

Patk

Sub ClearFilters()
With ActiveSheet
On Error Resume Next
If .AutoFilterMode = True Then
Debug.Print "autofilter on detected"
.ShowAllData
End If
End With

End Sub



"Mike H" wrote:

I'll get it right in a minute

With ActiveSheet
On Error Resume Next
If .AutoFilterMode = True Then
.ShowAllData
End If
End With

Mike

"Mike H" wrote:

apologies that will remove the filter and I think you want to reset it to
all. Try this

With ActiveSheet
If .AutoFilterMode Then
.ShowAllData
End If
End With

Mike

"Mike H" wrote:

Try

If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False

Mike

"PatK" wrote:

I have a spreadsheet that, using VBA macros, I add rows to the end of the
table, based upon data in a database. HOwever, I have found that, if, for
whatever reason, I have a filter set on one or more columns at the time I
attempt the update, I get an error in the VBA code. My work around is to
simply ensure I have no filters set, before I run the code, but it would be
great if I could programmatically "unset" all filters on all columns, before
I do the row add activity.

Is there a quick/dirty way to do that?

thanks!

Patk

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Programmatically removing data filters

How are you running the macro?
Tools|Macro|macros|run????

And you could have changed the name in the code instead of renaming the
worksheet.



PatK wrote:

That sure seemed logical enough, but it is not working. Here is the code and
note that, while I have the sheet I wanted, active, and it clearly has a
filters set, and one of the columns filtered, the debug is not triggering (so
assume the showalldata wont' work, either). I also tried naming the sheet as
Dave noted..same result. What am I missing? I do have a popup menu open
that they use to "trigger" the event, but that should not be considered a
worksheet. I even tried executing it simlply from VB, to bypass the menu,
but no joy. Ideas? Thanks for all your help!

Patk

Sub ClearFilters()
With ActiveSheet
On Error Resume Next
If .AutoFilterMode = True Then
Debug.Print "autofilter on detected"
.ShowAllData
End If
End With

End Sub

"Mike H" wrote:

I'll get it right in a minute

With ActiveSheet
On Error Resume Next
If .AutoFilterMode = True Then
.ShowAllData
End If
End With

Mike

"Mike H" wrote:

apologies that will remove the filter and I think you want to reset it to
all. Try this

With ActiveSheet
If .AutoFilterMode Then
.ShowAllData
End If
End With

Mike

"Mike H" wrote:

Try

If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False

Mike

"PatK" wrote:

I have a spreadsheet that, using VBA macros, I add rows to the end of the
table, based upon data in a database. HOwever, I have found that, if, for
whatever reason, I have a filter set on one or more columns at the time I
attempt the update, I get an error in the VBA code. My work around is to
simply ensure I have no filters set, before I run the code, but it would be
great if I could programmatically "unset" all filters on all columns, before
I do the row add activity.

Is there a quick/dirty way to do that?

thanks!

Patk


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Programmatically removing data filters

With worksheets("Sheet9999")
'to remove the filter and the arrows
.AutoFilterMode = False
'or to just show all the data
If .FilterMode Then
.ShowAllData
End If
End With



PatK wrote:

I have a spreadsheet that, using VBA macros, I add rows to the end of the
table, based upon data in a database. HOwever, I have found that, if, for
whatever reason, I have a filter set on one or more columns at the time I
attempt the update, I get an error in the VBA code. My work around is to
simply ensure I have no filters set, before I run the code, but it would be
great if I could programmatically "unset" all filters on all columns, before
I do the row add activity.

Is there a quick/dirty way to do that?

thanks!

Patk


--

Dave Peterson
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
Pivot Table filters, especially DATE filters chris Excel Worksheet Functions 0 August 27th 08 04:33 AM
data filters cs2001 Excel Discussion (Misc queries) 1 May 4th 07 02:36 AM
Filters, Subtotal & Intacted Results after the filters' Removal kasiopi Excel Discussion (Misc queries) 5 February 24th 06 12:18 PM
Removing Add-ins programmatically from Excel 2003 using VBScript Dutch Gemini Excel Programming 3 August 30th 05 03:00 PM
Removing Checkboxes Programmatically Mark D'Agosta Excel Programming 4 October 21st 03 03:57 PM


All times are GMT +1. The time now is 03:27 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"