Thread
:
Macro to hide rows
View Single Post
#
2
Posted to microsoft.public.excel.programming
Don Guillett[_4_]
external usenet poster
Posts: 2,337
Macro to hide rows
does this help
Sub ifunprotect()
If ActiveSheet.ProtectContents < True Then Exit Sub
MsgBox "Hi"
End Sub
--
Don Guillett
SalesAid Software
"Alex" wrote in message
...
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 With Quote
Don Guillett[_4_]
View Public Profile
Find all posts by Don Guillett[_4_]