ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Print time (https://www.excelbanter.com/excel-programming/415436-print-time.html)

Patrick C. Simonds

Print time
 
In cell H87 I have the formula below which of course gives the time the file
is opened, but it seems I need to have the time the worksheet is printed.
The workbook tends to be open most of the day and is printed each time a
change is made.

=NOW()


Gary Keramidas

Print time
 
not sure i understand, but you can add something like this to the beginning of
your print routine

worksheets("Sheet1").range("D5").calculate
--


Gary


"Patrick C. Simonds" wrote in message
...
In cell H87 I have the formula below which of course gives the time the file
is opened, but it seems I need to have the time the worksheet is printed. The
workbook tends to be open most of the day and is printed each time a change is
made.

=NOW()




FSt1

Print time
 
hi
this macro might do it.
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Range("A1").Value = Time ' change to suit
' or if you need each time printed for records...
'Range("A65000").End(xlUp).Offset(1, 0).Value = Time
End Sub

regards
FSt1
"Patrick C. Simonds" wrote:

In cell H87 I have the formula below which of course gives the time the file
is opened, but it seems I need to have the time the worksheet is printed.
The workbook tends to be open most of the day and is printed each time a
change is made.

=NOW()



Dave Peterson

Print time
 
Maybe you could use the workbook_beforeprint event to have excel calculate.
Then the time/date will update.

This would go under the ThisWorkbook module:

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Application.Calculate
End Sub


"Patrick C. Simonds" wrote:

In cell H87 I have the formula below which of course gives the time the file
is opened, but it seems I need to have the time the worksheet is printed.
The workbook tends to be open most of the day and is printed each time a
change is made.

=NOW()


--

Dave Peterson

Rick Rothstein \(MVP - VB\)[_2528_]

Print time
 
You can do what you want by using a workbook event procedure. Right click
the Excel icon immediately to the left of the File menu item, select View
Code from the menu that pops up and copy/paste this code into the code
window that opened up...

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Worksheets("Sheet1").Range("H87").Value = Now
End Sub

Note that I was not entirely clear which worksheet you wanted this date in,
so I assumed Sheet1 for example purposes. What confused me somewhat is that
you said "...the time the WORKSHEET is printed" {emphasis mine}. If you
meant that you want the time saved on the particular worksheet you were
printing, then, assuming that worksheet would always be the active sheet
when you were printing it, just change the Worksheets("Sheet1") reference to
ActiveSheet instead. If you have some other need for where this date is
stored, you will have to provide a more detailed description of your needs.

Rick


"Patrick C. Simonds" wrote in message
...
In cell H87 I have the formula below which of course gives the time the
file is opened, but it seems I need to have the time the worksheet is
printed. The workbook tends to be open most of the day and is printed each
time a change is made.

=NOW()




All times are GMT +1. The time now is 03:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com