Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
mike
 
Posts: n/a
Default multiple headers in excel

I have a document which when printed needs 4 unique copies. Only the
information on the header changes, and the rest of the document stays the
same. Is there a way to assign multiple headers? Or, if i have to make
individual worksheets for all pages, is there a way to hide all but one of
them from view in the workbook but still print all four?
  #2   Report Post  
Posted to microsoft.public.excel.misc
Kevin B
 
Posts: n/a
Default multiple headers in excel

A macro similar to the one below would print 4 times with a different header
each time.

This was not tested, but it's rather straight forward.

Sub PrintFourCopies()
'
' PrintFourCopies Macro

'Object variables for the curent workbook
'and sheet 1 in the workbook
Dim wb As Workbook
Dim ws As Worksheet

'String variables for each of the four headers
Dim strHeader1 As String
Dim strHeader2 As String
Dim strHeader3 As String
Dim strHeader4 As String
'Variables for the array that holds each header value
Dim vararray As Variant
Dim varItems As Variant

Set wb = ActiveWorkbook
Set ws = wb.Worksheets("Sheet1")

'Assign each header variable its respective value
strHeader1 = "I'm the header for copy number 1."
strHeader2 = "I'm the header for copy number 2."
strHeader3 = "I'm the header for copy number 3."
strHeader4 = "I'm the header for copy number 4."
'Assign all the header variables to the array
vararray = Array(strHeader1, strHeader2, strHeader3, _
strHeader4)
varItems = vararray

'loop through the array changing the header with
'each printing.
For Each varItems In vararray
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = varItems
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1, _
Collate:=True
Next varItems

'standard housekeeping
Set wb = Nothing
Set ws = Nothing
End Sub

--
Kevin Backmann


"mike" wrote:

I have a document which when printed needs 4 unique copies. Only the
information on the header changes, and the rest of the document stays the
same. Is there a way to assign multiple headers? Or, if i have to make
individual worksheets for all pages, is there a way to hide all but one of
them from view in the workbook but still print all four?

  #3   Report Post  
Posted to microsoft.public.excel.misc
flummi
 
Posts: n/a
Default multiple headers in excel

Something like this:

Private Sub CommandButton1_Click()

With Worksheets("sheet1")
.PageSetup.LeftHeader = "Individual title 1"
.PrintOut
.PageSetup.LeftHeader = "Individual title 2"
.PrintOut

End With
End Sub

On the VBA help look for the keyword "pagesetup".

Regards

Hans

  #4   Report Post  
Posted to microsoft.public.excel.misc
mike
 
Posts: n/a
Default multiple headers in excel

Thanks to both of you! i will try both of these solutions. In the meantime
i fixeed the problem with a simple data validation list but it's rather
clunky so I'll try the more complex solutions.

Thanks again,

mike

"flummi" wrote:

Something like this:

Private Sub CommandButton1_Click()

With Worksheets("sheet1")
.PageSetup.LeftHeader = "Individual title 1"
.PrintOut
.PageSetup.LeftHeader = "Individual title 2"
.PrintOut

End With
End Sub

On the VBA help look for the keyword "pagesetup".

Regards

Hans


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
Multiple instances of Excel Carol Crowley Excel Discussion (Misc queries) 9 March 17th 06 06:18 PM
multiple sheets when importing into excel Nora Excel Worksheet Functions 1 January 30th 06 09:38 PM
how can i open multiple excel sheets separately srinu Excel Discussion (Misc queries) 1 July 8th 05 04:38 PM
Excel Headers Angelo Excel Discussion (Misc queries) 3 March 16th 05 12:46 PM
Excel Headers Angelo New Users to Excel 1 March 15th 05 10:52 PM


All times are GMT +1. The time now is 05:30 AM.

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

About Us

"It's about Microsoft Excel"