Syntax help for if

  • Thread starter Thread starter Dean
  • Start date Start date
D

Dean

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
 
Dim sh as Worksheet
for each sh in worksheets
if sh.visible = xlSheetVisible then
sh.Select
' protect or unprotect
end if
Next
 
Worked like a charm - thanks.

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top