© Matti Mattila, CPFA, CISA, CIA

Footer & Header Macro: Key strokes & Variables

Next item Previous menu
Recording the key strokes
Picture #1: Recorded key strokes
- First we record keystrokes that are needed to insert header and footer information and to change page orientation (portrait / landscape). The keystrokes are show in the picture #1 (to the right).
Variables
- The code needs to be edited so that a user will be able to change any header and footer information, and to change page orientation. We need seven variables for this.
- We want to reserve the worksheet's cells only to data that we analyze, so we will give values to variables in an Excel form (UserForm1).
- The variables, the place where their contents will be saved, contents of variables, and where in UserForm1 variables relate to are as follows.
  • HL; Left Header information; name of the organization; UserForm1.TextBox1
  • HC; Center Header Information; worksheet title; UserForm1.TextBox2
  • HR; Right Header Information, date when the worksheet was created; UserForm1.TextBox3
  • FL; Left Footer Information, name of the worksheet tab; UserForm1.TextBox4
  • HC; Center Footer Information (reserved); UserForm1.TextBox5
  • HR; Center Header Information, maker of the work sheet; UserForm1.TextBox6
  • ORT; changing page orientation; UserForm1.ComboBox1