Add date when printing a file

DSLA

Active Member
Joined
Jun 6, 2005
Messages
301
Hi,

How can i add a date to the excel page when it is printed out?

Somekind of macro?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hello,

Why not add the date in the Header or Footer?

or are you asking to add a date to the spreadsheet when Print is selected.

If so, put this code into the THIS_WORKBOOK code window

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Range("A1").Value = Format(Now(), "mm/dd/yy")
End Sub
 
Upvote 0
Yes that is what i meen, adding the date when printing out the document.

How do i use the code you sent?
(sorry for the noob question)
 
Upvote 0
Hello,

Select TOOLS --> MACRO --> VISUAL BASIC EDITOR (or press ALT+F11)

In the new window select VIEW --> PROJECT EXPLORER

You should see somewhere, something that looks like Windows Explorer. One of which will be VBAProject (your file name) expand this folder and you will see This Workbook, double click this and a window will appear, headed your filename, this is where you need to post the code.
 
Upvote 0
Thanks, i got it working. Is there a way i can add also the Hours and Minutes?
 
Upvote 0
Hello,

Change the code to this

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean) 
Range("A1").Value = Now()
End Sub
 
Upvote 0
I noticed that it enters the date to every sheet on the excel file, i would only need it only to some of the sheets, how can i do that?
 
Upvote 0
Hello,

Which sheets do you want this to work for? i.e. what are their names, and what position are they in from the left

e.g.

SHeet1, sheet2, sheet3


please give the names as a list as shown in the spreadsheet and specify which need the date code adding.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top