Here's one already built.
Sub hide_em()
ActiveWorkbook.Unprotect Password:="justme"
Worksheets(Array("sheet1", "Sheet3", _
"Sheet5")).Visible = False
ActiveWorkbook.Protect Password:="justme", Structure:=True, Windows:=True
End Sub
If you were to record doing this your code would look like so..........
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 03-19-2007 by Gord Dibben
'
ActiveWorkbook.Unprotect
Sheets(Array("Sheet1", "Sheet3", "Sheet5")).Select
ActiveWindow.SelectedSheets.Visible = False
ActiveWorkbook.Protect Structure:=True, Windows:=True
End Sub
Notice that no password is recorded so you have to add it as the hide_em sub
does.
Gord Dibben MS Excel MVP
On Mon, 19 Mar 2007 13:36:10 -0700, David S <David
(E-Mail Removed)>
wrote:
>Can an one tell me how to record a macro that will un-password protect a
>workbook then hide several worksheets then re-password protect the workbook?