| Cleaning the keystrokes
|
| - |
First, we remove all the rows that are not needed in the macro.
Only 15 rows will be left; they are shown in the picture #1.
Removing extra lines has two purposes: (1) no unwanted changes
will take place when running the macro; and (2)
the code remains simple and clear.
| |
 |
|
Picture #1: Unnecessary rows removed |
 |
|
Picture #2: Basic Code |
|
| Adding new rows
|
| - |
We add new rows in order to achieve the desired functionality.
The added rows are shown in red, blue ad green in picture #2.
| |
| - |
The code in red requires all variables to be defined (Option Explicit),
and defines (Dim) them as string.
ComboBox1 is initialized by adding two items in it ("Vertical"; "Horizontal").
| |
| - |
First command line in blue makes UserForm1 to be shown.
Rest of the code in blue sets values from UserForm1 to defined variables
(HL, HC, HR, FL, FC and FR).
| |
| - |
The commands in green put values of variables in the header and in the footer of the worksheet.
In the right header there will be two dates: date of creation (HR) and date of last save (&D).
| |
| - |
For sake of clarity and simplicity orientation is determined outside
of "With ActiveSheet.PageSetup" ... "End with"
| |
| |