Date update only on action????

G

gaba53

This is a small issue that has been pestering me for a few days now. I
had a request to add "Last Update: date" to the header in a report.
Actually there are three different reports on three different
worksheets in one workbook that are being used. These three reports
have some VBA associated with a command button click that refreshes
them when the button is clicked. I thought that I could just append
the current date to the header inside the button click action, but the
date keeps advancing to the current date. So, this morning when I
opened the report and did a print preview the date was today's date,
and I know that the report wasn't updated since yesterday.

Below is the what I am currently doing. Initially the function below
was a procedure that read in the current sheet name and just added the
text to the header inside of the procedure to whatever sheet was
given. This did the same thing so I thought that if I assign the value
to a variable and then just manually print the variable text to the
header there would be no way that it could automatically update ......
this is frustrating, please help.

Thanks in advance.

Public Function LastUpdatedToHeader()

LastUpdatedToHeader = "Last Updated: &D"

End Function
'''Then call inside button click action like...
Dim updatedLast as String
updatedLast = LastUpdatedToHeader()
ActiveSheet.PageSetup.LeftHeader = updatedLast
 
G

Guest

&D says to print the current date.

Public Function LastUpdatedToHeader()

LastUpdatedToHeader = "Last Updated: " & format(Date,"mm/dd/yyyy")

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top