ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Syntax help for if (https://www.excelbanter.com/excel-programming/376479-syntax-help-if.html)

Dean[_8_]

Syntax help for if
 
Currently, I have a macro that protects or unprotects all sheets. However,
sometimes a couple of the sheets are hidden. How do I modify (if, then or
something like that) the code below to say, if "Summary" sheet is hidden,
ignore the protection of it? Right now, for example, I have, the following
inside the macro (where unprotectPW_Sheet is a macro that unprotects the
current sheet):

Sheets("Summary").Select
UnProtectPW_Sheet

Actually, maybe, if it is hidden, I should unhide it, protect it, then
rehide it. How about that?

Thanks!
Dean



Tom Ogilvy

Syntax help for if
 
Dim sh as Worksheet
for each sh in worksheets
if sh.visible = xlSheetVisible then
sh.Select
' protect or unprotect
end if
Next

--
Regards,
Tom Ogilvy



"Dean" wrote:

Currently, I have a macro that protects or unprotects all sheets. However,
sometimes a couple of the sheets are hidden. How do I modify (if, then or
something like that) the code below to say, if "Summary" sheet is hidden,
ignore the protection of it? Right now, for example, I have, the following
inside the macro (where unprotectPW_Sheet is a macro that unprotects the
current sheet):

Sheets("Summary").Select
UnProtectPW_Sheet

Actually, maybe, if it is hidden, I should unhide it, protect it, then
rehide it. How about that?

Thanks!
Dean




Dean[_8_]

Syntax help for if
 
Worked like a charm - thanks.

"Tom Ogilvy" wrote in message
...
Dim sh as Worksheet
for each sh in worksheets
if sh.visible = xlSheetVisible then
sh.Select
' protect or unprotect
end if
Next

--
Regards,
Tom Ogilvy



"Dean" wrote:

Currently, I have a macro that protects or unprotects all sheets.
However,
sometimes a couple of the sheets are hidden. How do I modify (if, then
or
something like that) the code below to say, if "Summary" sheet is hidden,
ignore the protection of it? Right now, for example, I have, the
following
inside the macro (where unprotectPW_Sheet is a macro that unprotects the
current sheet):

Sheets("Summary").Select
UnProtectPW_Sheet

Actually, maybe, if it is hidden, I should unhide it, protect it, then
rehide it. How about that?

Thanks!
Dean







All times are GMT +1. The time now is 03:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com