Header and Footer using a Macro

In this lesson I will show you how to create a macro that automatically adds a header and footer to your spreadsheet.

The first thing you have to do is add some data to your worksheet (A). Otherwise we will not see much when we print preview (B). Close the print preview, and click the “Record Macro” button (1). Everyone knows where to find this function in their version, so I will not repeat it.

les06_image001_en

Give it a name, a shortcut and a description.les06_image002_en
I save this macro in “This Workbook”, for the simple reason that the macro is immediately available even on those files that you downloaded. Click OK when you’re done.

For your information:

les06_image003_enWhen you save a file with a macro, you must save as “Excel workbook with macros”.

Next open the “Preview” window and click the “Page Setup” button.

This opens the “Page Setup” dialog where you open the “Header / Footer” tab.
Click the “Custom Header” button.

les06_image004_en

And add to your header and click OK.

les06_image005_en
Do the same for the footer.

If you are done with the insertion of header and footer, close the preview window and you stop recording the macro.

Now, if you use the keyboard shortcut Ctrl Shift K in any worksheet, then the header and footer text is added.

Awesome!
You've completed Lesson 6
START NEXT LESSON