Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Printing to header/footer programatically

I would like to be able to set a message to print in the footer/header of a
printed page depending on certain criteria in the spreadsheet.

Can someone suggest/advise how I could go about this.

Thanks in advance
Dean
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Printing to header/footer programatically

Dean,
A starter (from recording a macro as I added header and footer
to a worksheet). Change the header /footer sections as required according to
your selection criteria.

e.g

With ActiveSheet.PageSetup


If condition = criteria then
.LeftHeader=' .... whatever .."
else
.LeftHeader= " ... something else .."
End If
.....

End With



Range("A1:J32").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$J$32"

With ActiveSheet.PageSetup
' Header Sections .......
.LeftHeader = "My Left Header Section"
.CenterHeader = "My Centre Header Section"
.RightHeader = "My Right Header Section"
' Footer sections .....
.LeftFooter = "My Footer Left"
.CenterFooter = "My Footer Centre"
.RightFooter = "My Footer Right"

End With


HTH


"Dean" wrote:

I would like to be able to set a message to print in the footer/header of a
printed page depending on certain criteria in the spreadsheet.

Can someone suggest/advise how I could go about this.

Thanks in advance
Dean

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Printing to header/footer programatically

You would want to put such code in the BeforePrint event. If you are not
familiar with events, see Chip Pearson's page on events

http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy

"Toppers" wrote in message
...
Dean,
A starter (from recording a macro as I added header and

footer
to a worksheet). Change the header /footer sections as required according

to
your selection criteria.

e.g

With ActiveSheet.PageSetup


If condition = criteria then
.LeftHeader=' .... whatever .."
else
.LeftHeader= " ... something else .."
End If
....

End With



Range("A1:J32").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$J$32"

With ActiveSheet.PageSetup
' Header Sections .......
.LeftHeader = "My Left Header Section"
.CenterHeader = "My Centre Header Section"
.RightHeader = "My Right Header Section"
' Footer sections .....
.LeftFooter = "My Footer Left"
.CenterFooter = "My Footer Centre"
.RightFooter = "My Footer Right"

End With


HTH


"Dean" wrote:

I would like to be able to set a message to print in the footer/header

of a
printed page depending on certain criteria in the spreadsheet.

Can someone suggest/advise how I could go about this.

Thanks in advance
Dean



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Printing to header/footer programatically

You can use VBA to set the BeforePrint to print the same footer


Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet
If .Range("A1") = "my value" Then
.PageSetup.LeftFooter = "Some text"
End If
End With
End Sub


'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Dean" wrote in message
...
I would like to be able to set a message to print in the footer/header of

a
printed page depending on certain criteria in the spreadsheet.

Can someone suggest/advise how I could go about this.

Thanks in advance
Dean



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to prevent auto scaling of header and footer when printing user123 Excel Discussion (Misc queries) 0 January 22nd 07 05:00 PM
Excel 2007 - Header/Footer Printing problems JSpence2003 Excel Discussion (Misc queries) 3 November 14th 06 05:50 PM
Template for printing-orientation, header-footer setup John Sullivan Excel Worksheet Functions 0 July 22nd 05 05:12 PM
Changing Pivot Range Programatically - header row issue Scott Lyon[_2_] Excel Programming 3 July 22nd 04 04:29 AM
Changing (Part of) Header Without Changing Footer or Rest of Header Paul Cross Excel Programming 3 May 20th 04 10:42 PM


All times are GMT +1. The time now is 04:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"