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 |
All times are GMT +1. The time now is 09:47 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com