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

I have the following code that runs when a button in clicked, which works
very well. However, if the sheet is unprotected when the button is clicked,
an error msg. appears the next time the button is clicked indicating that the
password you selected is incorrect. I know that what is happening is that
that the sheet is being protected again in this code. I've asked the admin
for this file to quit clicking the button when the sheet is unprotected, but
I can't count on that. Is there a way to hide a button if a sheet is
unprotected? If not, is there a better way to write this code that will hide
rows Cells(rw, 1).Range("D1:W1")) = 0? Thank you very much.

Sub Hide_Rows_BldgG()
Dim rw As Long
Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:="grencr"


With ActiveSheet
For rw = 14 To 73
If Application.WorksheetFunction.CountA( _
.Cells(rw, 1).Range("D1:W1")) = 0 Then _
.Rows(rw).Hidden = True
Next rw

End With
ActiveSheet.Protect Password:="grencr"
Application.ScreenUpdating = True

End Sub
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 code to hide rows and not calculate hidden rows bradmcq Excel Discussion (Misc queries) 0 September 1st 09 12:38 AM
Macro to hide rows lightbulb Excel Discussion (Misc queries) 4 July 11th 08 06:13 PM
hide rows with macro Macro to hide rows in spreadwsheet Excel Discussion (Misc queries) 3 May 12th 05 05:02 PM
macro to hide rows david Excel Discussion (Misc queries) 3 April 8th 05 03:25 PM
Macro to hide rows Jeffrey Marcellus Excel Programming 0 September 5th 03 07:09 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"