Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
With Worksheets("sheet1")
.PageSetup.RightHeader = "This is what's in A1: " & .Range("A1").Text
.PageSetup.LeftHeader = Format(Date, "mmmm dd, yyyy")
End With
End Sub
This kind of code goes behind the ThisWorkbook module.
Thank you very much. Of your name I guess you are of Swedish origin. I
myself, is Norwegian.
I would like to know if VisualBasic,VBA is build in Excel 2003 or must I
have the whole program to make a macro? I think I have a CD with some old
program on, and I have some programming experience mainly with dBASE and a
litle Pascal and I have tried some VBA as well (very little).
Yours
Magnar Myklebust (retired)
Ellingsrudlia 24
1400 Ski
Norway
E-mail (e-mail address removed)
Thank you for your answer.
I have no problems getting the code in the editor, and it compiles) without
any messages. But when I put some text i A1 inn sheet1 I cannot see any
result in neither heading noe footer after having run the program. I need a
litle detailed help here. I have programmed in dBASE and a little in Pascal
(and Simula/Basic/Fortran) but that was many years ago. And this is a whole
new story. I use a downloaded version of excel 2003.I think thou I understand
the main lines in the program. But I keep getting no result . I supose I may
put the program in the wrong place- shall it be placed in the sheet1 or in a
module?
Thank you
Magnar M.
Make sure you put the code under the ThisWorkbook module.
And this routine isn't designed to run on demand (manually). Instead it runs
when you print or printpreview.
Thank you for your answer.
I have no problems getting the code in the editor, and it compiles) without
any messages. But when I put some text i A1 inn sheet1 I cannot see any
result in neither heading noe footer after having run the program. I need a
litle detailed help here. I have programmed in dBASE and a little in Pascal
(and Simula/Basic/Fortran) but that was many years ago. And this is a whole
new story. I use a downloaded version of excel 2003.I think thou I understand
the main lines in the program. But I keep getting no result . I supose I may
put the program in the wrong place- shall it be placed in the sheet1 or in a
module?
Thank you
Magnar M.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.