Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
applying worksbook protection via a Macro
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? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
applying worksbook protection via a Macro
Sub ProtectWkbandHideSheets()
ActiveWorkbook.Unprotect Password = "123" Sheets("Sheet2").Select ActiveWindow.SelectedSheets.Visible = False Sheets("Sheet3").Select ActiveWindow.SelectedSheets.Visible = False ActiveWorkbook.Protect Password = "123" End Sub Change sheets and P/W to suit. Corey.... "David S" <David wrote in message ... 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? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
applying worksbook protection via a Macro
Here's one already built.
Sub hide_em() ActiveWorkbook.Unprotect Password:="justme" Worksheets(Array("sheet1", "Sheet3", _ "Sheet5")).Visible = False ActiveWorkbook.Protect Password:="justme", Structu=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 Structu=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 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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
populate nonblank cells from worksbook to another | Excel Worksheet Functions | |||
Applying Protection Perameters With VBA Code | Excel Programming | |||
Applying Protection To Multiple Sheets | New Users to Excel | |||
Removing and Applying protection in VBA | Excel Programming | |||
Applying protection to an Excel Expense Report | Excel Programming |