Easy question on formatting

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a workbook with 14 worksheets. Each sheet has specific formatting and
all the sheets are protected.

Is there a macro I can build to unlock all sheets and to lock all sheets
that I can run when needed and block from view with a password?

Also, I did all the page set up manually. I'd like to do this with code
....so much easier to manage..but I can I have the code run when the
speadsheet is opened. Below is a sample of one of the sheets page setup, but
it doesn't work

With ActiveSheet.PageSetUp

.PrintTitleRows = "$1:$1"
.CenterHeader = "Report for " & Date
.CenterFooter = "November"
.RightFooter = "&P"
.PrintArea = "$A:$G"
.PrintGridlines = True
.Orientation = xlPortrait
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.CenterHorizontally = True


End With
 
Protecting/unprotecting the sheets can be done by using a macro recorded in a
separate workbook. That will keep it secure and available only to you.

Example:

Sub ProtectAllSheets()

Windows("file_to_protect.xls").Activate

Application.ScreenUpdating = False

For i = 1 To 14
Sheets(i).Select

ActiveSheet.Protect Password:="password"
ActiveSheet.EnableSelection = xlUnlockedCells

Next i

ActiveWorkbook.Protect Password:="password", Structure:=True,
Windows:=False

Application.ScreenUpdating = True

End Sub

Similar code can be written to unlock the sheets.

Regards...
 

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