To get to the Visual Basic Editor go to the Tools Menu/Macro/Visual Basic
Editor (or press Alt F11). Inside the Visual Basic Editor go to the Insert
Menu and select Module. This will add a code module to your workbook. In
the code module you can start a visual basic sub routine by typing code like
the following (or just copy and past this code):
Sub SetFooterHeaders()
Dim sht As WorkSheet
For Each sht In ThisWorkBook.Sheets
sht.PageSetup.CenterHeader = sht.Name
sht.PageSetup.RightFooter = "Run Date: " & Date
Next
End Sub
Now, when you go back to the worksheet, click on Tools/Macro/Macros and you
will see your subroutine "SetFooterHeaders" listed in the Macros list.
Select your macro and click on the Run button. The macro above will iterated
(loop) through all the sheets in your workbook and add the sheet name to the
respective sheet header and Today's Date as the footer. Date is a built-in
Visual Basic function that returns Today's Date. You can now go into the
PrintPreview screen and see your Headers and footers for each sheet. Note:
you could also run the code above from the Visual Basic Editor by placing the
mouse cursor anywhere inside the subroutine and pressing the F5 key.
Rich
"Bill" wrote:
I've created macros with Excel (or Visual Basic?) recording keystrokes/mouse
clicks, but I've never interacted with VB directly.
I want to add a time / date stamp in a worksheet that will change each time
I save a workbook.
Not even sure where to begin.
--
Thanks,Bill