Prevent Header or Footer Change

zKy

Board Regular
Joined
Oct 22, 2008
Messages
90
How do I prevent users from changing the header or footer of a spreadsheet? Neither worksheet nor workbook protection works.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
I assume your users need to change some things in the workbook? Because otherwise it would be too easy to just password protect the workbook.
 
Upvote 0
Certain cells are unlocked.

Protecting the entire workbook doesn't prevent users from changing the headers and footers though.

I assume your users need to change some things in the workbook? Because otherwise it would be too easy to just password protect the workbook.
 
Upvote 0
You could place some VBA code in your workbook's Before_Save event so that even if a user changes the header/footer it will revert to your settings each time they save the file. Something like this might work:

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
    With ws.PageSetup
        .LeftHeader = ActiveSheet.Range("A100").Value
        .CenterHeader = ""
        .RightHeader = ws.Name
        .LeftFooter = ActiveWorkbook.Name
        .CenterFooter = ""
        .RightFooter = Date & "  " & Time
    End With
Next ws
End Sub

I'd use this as an example and input your settings as needed. You could reference certain cells (protected, of course!) for your header/footer. See my example above of using cell A100.
 
Upvote 0
I'm actually using BeforePrint right now but was wondering whether there's any way to prevent the changes to begin with.

Thanks anyways KMSeattle.(y)
 
Upvote 0
I'm actually using BeforePrint right now but was wondering whether there's any way to prevent the changes to begin with.

Thanks anyways KMSeattle.(y)
Great minds think alike, right? :biggrin:

I'm not sure how to prevent those change then... hopefully somebody else here can help!
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,040
Members
449,063
Latest member
ak94

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top