Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Autmatically remove filters from all worksheets

I'm creating spreadsheets that contain buttons/macros to filter for
specific criteria. I want all records/rows to be shown when the
workbook is opened. I have 2 macros to accomplish this. One is attached
to a button which appears on every worksheet to remove any filters.

Sub ShowAll()
'
' ShowAll Macro
' Macro recorded 3/11/2005 by Dave Bellamy

Range("a1:J62").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("S5:Z6"), Unique:=False
Range("c4").Select

End Sub

I used blank filter criteria instead of other methods that I found to
remove filters because none of the others worked in a protected sheet.

The second macro goes through all sheets in the workbook and removes
all filters automatically on opening. Or it should. It calls the first
program to do so. I've stepped through the macro, and it goes to both
sheets (I'm testing with 2 sheets, more will come later so I want the
macro to run on however many sheets there are in the workbook). But it
doesn't remove the filter in the second sheet.

Sub Auto_Open()
Dim Wks As Object
For Each Wks In ThisWorkbook.Worksheets
On Error Resume Next
ShowAll
Next Wks
End Sub

Does anyone know what's wrong?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Autmatically remove filters from all worksheets

Hi, Try the following

Sub Auto_Open()
For Each Wks In ThisWorkbook.Worksheets
On Error Resume Next
Wks.ShowAllData
Next Wks
End Sub

--
Cheers
Nigel



"davegb" wrote in message
ps.com...
I'm creating spreadsheets that contain buttons/macros to filter for
specific criteria. I want all records/rows to be shown when the
workbook is opened. I have 2 macros to accomplish this. One is attached
to a button which appears on every worksheet to remove any filters.

Sub ShowAll()
'
' ShowAll Macro
' Macro recorded 3/11/2005 by Dave Bellamy

Range("a1:J62").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("S5:Z6"), Unique:=False
Range("c4").Select

End Sub

I used blank filter criteria instead of other methods that I found to
remove filters because none of the others worked in a protected sheet.

The second macro goes through all sheets in the workbook and removes
all filters automatically on opening. Or it should. It calls the first
program to do so. I've stepped through the macro, and it goes to both
sheets (I'm testing with 2 sheets, more will come later so I want the
macro to run on however many sheets there are in the workbook). But it
doesn't remove the filter in the second sheet.

Sub Auto_Open()
Dim Wks As Object
For Each Wks In ThisWorkbook.Worksheets
On Error Resume Next
ShowAll
Next Wks
End Sub

Does anyone know what's wrong?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Autmatically remove filters from all worksheets

Tried it, Nigel, does the same thing mine does. Removes filters on the
first sheet, but not the other.
Thanks for trying!

  #4   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default Autmatically remove filters from all worksheets

davegb,

When you start switching between more than one sheet you need to qualify to
excel which sheet you are refering to

try
Sub ShowAll()
'
' ShowAll Macro
' Macro recorded 3/11/2005 by Dave Bellamy

activesheet. Range("a1:J62").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
activesheet.Range("S5:Z6"), Unique:=False
activesheet.Range("c4").Select

End Sub

Sub Auto_Open()
Dim Wks As Object
For Each Wks In ThisWorkbook.Worksheets
On Error Resume Next
wks.activate
ShowAll
Next Wks
End Sub


ben
"davegb" wrote:

I'm creating spreadsheets that contain buttons/macros to filter for
specific criteria. I want all records/rows to be shown when the
workbook is opened. I have 2 macros to accomplish this. One is attached
to a button which appears on every worksheet to remove any filters.

Sub ShowAll()
'
' ShowAll Macro
' Macro recorded 3/11/2005 by Dave Bellamy

Range("a1:J62").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("S5:Z6"), Unique:=False
Range("c4").Select

End Sub

I used blank filter criteria instead of other methods that I found to
remove filters because none of the others worked in a protected sheet.

The second macro goes through all sheets in the workbook and removes
all filters automatically on opening. Or it should. It calls the first
program to do so. I've stepped through the macro, and it goes to both
sheets (I'm testing with 2 sheets, more will come later so I want the
macro to run on however many sheets there are in the workbook). But it
doesn't remove the filter in the second sheet.

Sub Auto_Open()
Dim Wks As Object
For Each Wks In ThisWorkbook.Worksheets
On Error Resume Next
ShowAll
Next Wks
End Sub

Does anyone know what's wrong?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Autmatically remove filters from all worksheets

Ben remove this if mailing direct,
Bingo! This one worked! You win the prize!



  #6   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default Autmatically remove filters from all worksheets

yeah let's not go into just how much of a pain in the butt that was trying to
figure out when i first started changing sheets on my first project.

"davegb" wrote:

Ben remove this if mailing direct,
Bingo! This one worked! You win the prize!


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Autmatically remove filters from all worksheets

I can imagine! Had the same experience with learning VBA several times.
Thanks for passing it along!

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Autmatically remove filters from all worksheets

Pass in the worksheet object to the showall procedure something like this

Sub ShowAll(byval wks as worksheet)
'
' ShowAll Macro
' Macro recorded 3/11/2005 by Dave Bellamy

wks.Range("a1:J62").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
wks.Range("S5:Z6"), Unique:=False
wks.Range("c4").Select

End Sub

That is untested but I think it will work...

HTH


"davegb" wrote:

I'm creating spreadsheets that contain buttons/macros to filter for
specific criteria. I want all records/rows to be shown when the
workbook is opened. I have 2 macros to accomplish this. One is attached
to a button which appears on every worksheet to remove any filters.

Sub ShowAll()
'
' ShowAll Macro
' Macro recorded 3/11/2005 by Dave Bellamy

Range("a1:J62").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("S5:Z6"), Unique:=False
Range("c4").Select

End Sub

I used blank filter criteria instead of other methods that I found to
remove filters because none of the others worked in a protected sheet.

The second macro goes through all sheets in the workbook and removes
all filters automatically on opening. Or it should. It calls the first
program to do so. I've stepped through the macro, and it goes to both
sheets (I'm testing with 2 sheets, more will come later so I want the
macro to run on however many sheets there are in the workbook). But it
doesn't remove the filter in the second sheet.

Sub Auto_Open()
Dim Wks As Object
For Each Wks In ThisWorkbook.Worksheets
On Error Resume Next
ShowAll
Next Wks
End Sub

Does anyone know what's wrong?


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Autmatically remove filters from all worksheets

Thanks Jim, but it didn't work either!

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Autmatically remove filters from all worksheets





*** Sent via Developersdex http://www.developersdex.com ***


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
Remove or delete lists/filters. Champ Excel Discussion (Misc queries) 1 December 10th 09 12:35 PM
Remove filters/lists from multiple columns but not all. Champ Excel Discussion (Misc queries) 0 December 10th 09 06:49 AM
How do I remove auto filters from a file I exported out of Salesfo SusanM Excel Worksheet Functions 0 May 7th 09 06:18 PM
Remove filters Tom Excel Discussion (Misc queries) 5 March 23rd 07 09:57 AM
Filters on Protected Worksheets CiaraG[_3_] Excel Programming 2 November 20th 03 11:10 AM


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