Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Automate Page Header Text

Is there a code I can apply in the page header that will read the mininum and
maximum date in a range of cells?

For example:
I would like the page header for some worksheets within a workbook to read
"Data Report from 'minimum date here' thru 'maximum date here'.

So, let's say that I had a pivot table that is refreshing the summarized
data from worksheet1 that has dates in some cells. I would like to refer
back to that so I can automate a date range in the page header for my pivot
table. Is this possible?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Automate Page Header Text

You could use a macro:

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)

Dim MaxDate As Date
Dim MinDate As Date

With Me.Worksheets("sheet1")
MinDate = Application.Min(.Range("a1:X1"))
MaxDate = Application.Max(.Range("a1:x1"))

.PageSetup.CenterHeader = "Data Report from " & _
Format(MinDate, "mm/dd/yyyy") & _
" through " & _
Format(MaxDate, "mm/dd/yyyy")

End With
End Sub

Change the sheet name and range address (both spots) to what you need.

This goes behind the ThisWorkbook module.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm




Vicki wrote:

Is there a code I can apply in the page header that will read the mininum and
maximum date in a range of cells?

For example:
I would like the page header for some worksheets within a workbook to read
"Data Report from 'minimum date here' thru 'maximum date here'.

So, let's say that I had a pivot table that is refreshing the summarized
data from worksheet1 that has dates in some cells. I would like to refer
back to that so I can automate a date range in the page header for my pivot
table. Is this possible?


--

Dave Peterson
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 insert Header will full text across page Janet A. Thompson Excel Discussion (Misc queries) 0 January 12th 10 02:14 PM
Automate 'Publish as Web Page'? dyowee Excel Discussion (Misc queries) 2 May 5th 08 01:19 PM
Excel header how to automate for new worksheets lee Setting up and Configuration of Excel 1 November 14th 07 01:25 AM
Omit header from first page without embedding header in code ibvalentine Excel Worksheet Functions 6 August 28th 07 05:10 AM
Without using Header/Footer, how would I anchor text on a page? R Stanton Excel Discussion (Misc queries) 1 January 22nd 07 08:59 PM


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

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"