Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Loop through worksheets to unhide rows

Hi all,

I'm trying to write a sub where the user will click a box ("Hide Unused
Rows in all Worksheets") and the macro will go through each worksheet
in my workbook and will unhide all of the hidden rows. Both the
workbook and each individual worksheet have protection - we'll assume
both passwords are "password" for this example.

Issues:

1) The macro below runs, but it is not unhiding the rows.
2) The way I've written it will check 200 rows in each worksheet. Is
there an easy way for it to check only through the last active row on
each worksheet?

Sub UnhideAllRowsWorkbook()

' Unhides all rows throughout the workbook

Application.ScreenUpdating = False
ActiveWorkbook.Unprotect Password:="Password"
Dim WS As Worksheet
For Each WS In ThisWorkbook.Worksheets
WS.Unprotect Password:="Password"
Rows("1:200").EntireRow.Hidden = False
WS.Protect Password:="Password",
userinterfaceonly:=True, AllowFormattingCells:=True,
AllowFormattingColumns:=True, AllowFormattingRows:=True
WS.EnableSelection = xlNoRestrictions
Next WS
ActiveWorkbook.Protect Password:="Password", Structu=True,
Windows:=True
Cells(1, 1).Select
Application.ScreenUpdating = True
MsgBox "All rows throughout the workbook are now visible.",
vbOKOnly
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Loop through worksheets to unhide rows



Application.ScreenUpdating = False
ActiveWorkbook.Unprotect Password:="Password"
Dim WS As Worksheet
For Each WS In ThisWorkbook.Worksheets
WS.Unprotect Password:="Password"
' change made:
ws.UserRange.EntireRow.Hidden = False
WS.Protect Password:="Password",
userinterfaceonly:=True, AllowFormattingCells:=True,
AllowFormattingColumns:=True, AllowFormattingRows:=True
WS.EnableSelection = xlNoRestrictions
Next WS
ActiveWorkbook.Protect Password:="Password", Structu=True,
Windows:=True
Cells(1, 1).Select
Application.ScreenUpdating = True
MsgBox "All rows throughout the workbook are now visible.",
vbOKOnly
End Sub

--
Regards,
Tom Ogilvy


"Punsterr" wrote in message
oups.com...
Hi all,

I'm trying to write a sub where the user will click a box ("Hide Unused
Rows in all Worksheets") and the macro will go through each worksheet
in my workbook and will unhide all of the hidden rows. Both the
workbook and each individual worksheet have protection - we'll assume
both passwords are "password" for this example.

Issues:

1) The macro below runs, but it is not unhiding the rows.
2) The way I've written it will check 200 rows in each worksheet. Is
there an easy way for it to check only through the last active row on
each worksheet?

Sub UnhideAllRowsWorkbook()

' Unhides all rows throughout the workbook

Application.ScreenUpdating = False
ActiveWorkbook.Unprotect Password:="Password"
Dim WS As Worksheet
For Each WS In ThisWorkbook.Worksheets
WS.Unprotect Password:="Password"
Rows("1:200").EntireRow.Hidden = False
WS.Protect Password:="Password",
userinterfaceonly:=True, AllowFormattingCells:=True,
AllowFormattingColumns:=True, AllowFormattingRows:=True
WS.EnableSelection = xlNoRestrictions
Next WS
ActiveWorkbook.Protect Password:="Password", Structu=True,
Windows:=True
Cells(1, 1).Select
Application.ScreenUpdating = True
MsgBox "All rows throughout the workbook are now visible.",
vbOKOnly
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Loop through worksheets to unhide rows

Tom,

Thanks for your quick response. However, there appears to be an error
with the change you suggested (ws.UserRange.EntireRow.Hidden = False).
I get a compile error "method or data member not found."

I also am still curious as to why my initial attempt didn't work (just
unhiding all of rows 1-200 on each worksheet). The macro runs, it
doesn't error out, but yet it doesn't unhide the rows. Is there an
issue with it being called from another sub?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Loop through worksheets to unhide rows

ws.UserRange.EntireRow.Hidden = False
was a typo

it should be

ws.UsedRange.EntireRow.Hidden = False

it didn't work for the same reason as your next post. The unqualified rows
refered to the activesheet.

--
Regards,
Tom Ogilvy

"Punsterr" wrote in message
oups.com...
Tom,

Thanks for your quick response. However, there appears to be an error
with the change you suggested (ws.UserRange.EntireRow.Hidden = False).
I get a compile error "method or data member not found."

I also am still curious as to why my initial attempt didn't work (just
unhiding all of rows 1-200 on each worksheet). The macro runs, it
doesn't error out, but yet it doesn't unhide the rows. Is there an
issue with it being called from another sub?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Loop through worksheets to unhide rows

Got it. Thanks a bunch!



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
Slow VBA code....Hide/Unhide Loop Tami Excel Worksheet Functions 2 August 4th 09 01:53 AM
Enabling option „Format rows“ to hide/unhide rows using VBA-code? ran58 Excel Discussion (Misc queries) 0 July 28th 09 03:46 PM
unhide row does not unhide the hidden rows nikita Excel Worksheet Functions 4 May 24th 08 02:59 PM
Unhide Worksheets Randy L Excel Discussion (Misc queries) 0 November 30th 06 03:58 PM
unhide several worksheets jggsfl Excel Discussion (Misc queries) 1 July 11th 06 07:45 PM


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