help with macro

S

santaviga

Sorry for the misunderstanding, seemingly you cant have 2 before save events
or you will get an ambiguous error, any ideas on resloving. Below is all my
code.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Call ProtectAllSheets
End Sub

Sub ProtectAllSheets()
Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Protect Password:="****"
Next n
Application.ScreenUpdating = True
End Sub

Sub UnprotectAllSheets()
Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Unprotect Password:="****"
Next n
Application.ScreenUpdating = True
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim SH As Object
Dim SH2 As Object
With Me
Set SH = .Sheets("Sheet3")
Set SH2 = .Sheets("Sheet8")
End With
SH.PageSetup.RightFooter = Format(Now, "dd-mmm-yy")
SH2.PageSetup.RightFooter = "Relief Shifts " & Format(Now,
"dd-mmm-yy")
End Sub

Many thanks
 
S

santaviga

Also on this the subscript is out of range.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim SH As Object
Dim SH2 As Object
With Me
Set SH = .Sheets("Sheet3")
Set SH2 = .Sheets("Sheet8")
End With
SH.PageSetup.RightFooter = Format(Now, "dd-mmm-yy")
SH2.PageSetup.RightFooter = "Relief Shifts " & Format(Now,
"dd-mmm-yy")
End Sub
 

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

Top