View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bdadmin Bdadmin is offline
external usenet poster
 
Posts: 4
Default Date Range displayed in header

That worked great. Thanks for the help

BD

"Dave Peterson" wrote:

A header like a print header?

You have to do it manually or use a macro.

Rightclick on the Excel icon to the left of the File dropdown on the worksheet
menu bar.
Select view code and paste this into the code window:

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim myMin As Date
Dim myMax As Date
Dim myStr As String
Dim myRng As Range

With Worksheets("sheet9999")
Set myRng = .Range("a:a")
myMin = Application.Min(myRng)
myMax = Application.Max(myRng)
myStr = "Date Range: " & Format(myMin, "mm/dd/yyyy") _
& " - " & Format(myMax, "mm/dd/yyyy")
.PageSetup.LeftHeader = myStr
End With
End Sub

Change sheet9999 to the correct name.



Bdadmin wrote:

Thanks for the reply. That works great in a cell on the worksheet, but how do
I get it to display in the header?

Thanks in advance.
BD

"Dave Peterson" wrote:

=text(min(a1:a10),"m/d/yyyy") & " - " & text(max(a1:a10),"m/d/yyyy")

Bdadmin wrote:

I am attempting to put the range of MIN and MAX dates pulled from a column. I
would like it to look like:

Date Range: 9/6/2006 - 10/26/2006

from a column like this:

Date
09/06/2006
09/06/2006
09/10/2006
10/12/2006
10/26/2006

Thanks in advance
BD

--

Dave Peterson


--

Dave Peterson