View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Formatted Date in header applied with a macro

Your question could be answered both ways. If you manually create an header
you can put the date into the header two ways. One by simply typing in the
date. the second method is to use the date function to add the date to the
header. Typing in the Date is static, using the function is not static.

Let me expain futher. If we were working on the spread sheet there are
three ways of entering a date from VBA code:

1) Range("A1") = "9/13/08"
2) Range("A1") = format(date,"mm/dd/yy")
3) Range("A1").Formula = "=Now()"
Range("A1").NumberFormat = "mm/dd/yy"

The 1st item is static and will never change. the second method will change
every time the macro is run. The third method will change every time the
workbook is opened.

The same will apply to the header depending on which method you use. The
qustion you asked I couldn't answer because I didn't know if you were
refering to the 2nd or 3rd method.


"Kay" wrote:

Joel,

IF you could get me started on how to do that I would appreciate it, but, I
also want to know if my assumption is correct or did I just do something
incorrectly in writing the code? Does adding the format function to the code
cause it to become a static date?

Thanks!

"Joel" wrote:

Maybe run the macro using one of the events like Workbook Open or Before Print.

"Kay" wrote:

Hello all,

I was just looking at the post for formatting the date in a header. My
question concerns how to get the date to update without re-running the macro.
If you use the default date as added via the header footer toolbar, it
updates fine, but format(date, mmmm dd, yyyy) does not.