Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Macro to Un Hide filtered rows

I have this Macro

Sub Macro2()
Const csPWORD As String = "123"
ActiveWorkbook.Worksheets("broker").Unprotect Password:=csPWORD
ActiveSheet.ShowAllData
ActiveWorkbook.Worksheets("broker").Protect Password:=csPWORD
End Sub

I get a bug error if the sheet is already un filtered and the next step of
protecting the sheet again doesn't happen. How do I change this to search
first to see if the worksheet is filtered and if it is then proceed with the
rest of the Macro.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro to Un Hide filtered rows

One option would be to ignore the error;

Sub Macro2()
Const csPWORD As String = "123"
ActiveWorkbook.Worksheets("broker").Unprotect Password:=csPWORD
On error resume next
ActiveSheet.ShowAllData
on error goto 0
ActiveWorkbook.Worksheets("broker").Protect Password:=csPWORD
End Sub

HTH,
Keith

"JeffK" wrote:

I have this Macro

Sub Macro2()
Const csPWORD As String = "123"
ActiveWorkbook.Worksheets("broker").Unprotect Password:=csPWORD
ActiveSheet.ShowAllData
ActiveWorkbook.Worksheets("broker").Protect Password:=csPWORD
End Sub

I get a bug error if the sheet is already un filtered and the next step of
protecting the sheet again doesn't happen. How do I change this to search
first to see if the worksheet is filtered and if it is then proceed with the
rest of the Macro.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Macro to Un Hide filtered rows

Keith, worked like a charm,

Thanks

"ker_01" wrote:

One option would be to ignore the error;

Sub Macro2()
Const csPWORD As String = "123"
ActiveWorkbook.Worksheets("broker").Unprotect Password:=csPWORD
On error resume next
ActiveSheet.ShowAllData
on error goto 0
ActiveWorkbook.Worksheets("broker").Protect Password:=csPWORD
End Sub

HTH,
Keith

"JeffK" wrote:

I have this Macro

Sub Macro2()
Const csPWORD As String = "123"
ActiveWorkbook.Worksheets("broker").Unprotect Password:=csPWORD
ActiveSheet.ShowAllData
ActiveWorkbook.Worksheets("broker").Protect Password:=csPWORD
End Sub

I get a bug error if the sheet is already un filtered and the next step of
protecting the sheet again doesn't happen. How do I change this to search
first to see if the worksheet is filtered and if it is then proceed with the
rest of the Macro.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to Un Hide filtered rows

Sub Macro2()
Const csPWORD As String = "123"

With activeworkbook.worksheets("broker")

.unprotect password:=cspword

'to remove the filter and the arrows
.AutoFilterMode = False

'or to just show all the data and keep the arrows
If .FilterMode Then
.ShowAllData
End If

.protect password:=cspword
End With
End Sub

JeffK wrote:

I have this Macro

Sub Macro2()
Const csPWORD As String = "123"
ActiveWorkbook.Worksheets("broker").Unprotect Password:=csPWORD
ActiveSheet.ShowAllData
ActiveWorkbook.Worksheets("broker").Protect Password:=csPWORD
End Sub

I get a bug error if the sheet is already un filtered and the next step of
protecting the sheet again doesn't happen. How do I change this to search
first to see if the worksheet is filtered and if it is then proceed with the
rest of the Macro.


--

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
Macro to Un Hide filtered rows J_Knowles[_2_] Excel Programming 0 November 25th 09 11:50 PM
Macro code to hide rows and not calculate hidden rows bradmcq Excel Discussion (Misc queries) 0 September 1st 09 12:38 AM
Delete all filtered rows from a macro? Joe M Excel Programming 1 February 3rd 09 10:46 PM
Macro for counting the number of filtered rows DGillham[_5_] Excel Programming 4 January 9th 06 02:08 PM
Filtered Visible Rows & VBA Non-Filtered Rows Displayed QTE[_15_] Excel Programming 8 July 11th 04 02:21 AM


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