ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Session Times (https://www.excelbanter.com/excel-programming/413769-session-times.html)

will07

Session Times
 
Hello All,

Is it possible to add some code into a file that will show the session time
(in a cell)that a file is open or has been used.

thanks

Geoff K

Session Times
 
try something like this

put this into your ThisWorkBook module
Private Sub Workbook_Open()
With Sheets(1)
.Range("A1") = "Wbook opened at:"
.Range("A2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Sheets(1)
.Range("B1") = "Last closed at:"
.Range("B2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

hth

Geoff K

"will07" wrote:

Hello All,

Is it possible to add some code into a file that will show the session time
(in a cell)that a file is open or has been used.

thanks


Gary''s Student

Session Times
 
Private Sub Workbook_Open()
Sheets("Sheet1").Range("A1").Formula = "=now()"
Sheets("Sheet1").Range("A2").Value = Now
Sheets("Sheet1").Range("A3").Formula = "=a1-a2"
Sheets("Sheet1").Range("A3").NumberFormat = "h:mm:ss;@"
End Sub

Whenever the worksheet is calculated, A3 will display the session time.
--
Gary''s Student - gsnu200794


"will07" wrote:

Hello All,

Is it possible to add some code into a file that will show the session time
(in a cell)that a file is open or has been used.

thanks


Tom Ogilvy

Session Times
 
Just a thought, but wouldn't the workbook need to be saved to retain the
values?

--
Regards,
Tom Ogilvy


"Geoff K" wrote:

try something like this

put this into your ThisWorkBook module
Private Sub Workbook_Open()
With Sheets(1)
.Range("A1") = "Wbook opened at:"
.Range("A2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Sheets(1)
.Range("B1") = "Last closed at:"
.Range("B2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

hth

Geoff K

"will07" wrote:

Hello All,

Is it possible to add some code into a file that will show the session time
(in a cell)that a file is open or has been used.

thanks


Geoff K

Session Times
 
That's true and on reflectiion I think my interpretation of "has been used"
is not what the op was wanting. Gary's solution is of course on the mark for
the current session which is most probably what was required though it does
not provide for history.

Geoff K

"Tom Ogilvy" wrote:

Just a thought, but wouldn't the workbook need to be saved to retain the
values?

--
Regards,
Tom Ogilvy


"Geoff K" wrote:

try something like this

put this into your ThisWorkBook module
Private Sub Workbook_Open()
With Sheets(1)
.Range("A1") = "Wbook opened at:"
.Range("A2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Sheets(1)
.Range("B1") = "Last closed at:"
.Range("B2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

hth

Geoff K

"will07" wrote:

Hello All,

Is it possible to add some code into a file that will show the session time
(in a cell)that a file is open or has been used.

thanks


Geoff K

Session Times
 
Another solution as it fits your criteria (in a cell) can be found here with
Bob Philip's respons
http://www.microsoft.com/communities...6-35646daae260

hth

Geoff K

"Geoff K" wrote:

That's true and on reflectiion I think my interpretation of "has been used"
is not what the op was wanting. Gary's solution is of course on the mark for
the current session which is most probably what was required though it does
not provide for history.

Geoff K

"Tom Ogilvy" wrote:

Just a thought, but wouldn't the workbook need to be saved to retain the
values?

--
Regards,
Tom Ogilvy


"Geoff K" wrote:

try something like this

put this into your ThisWorkBook module
Private Sub Workbook_Open()
With Sheets(1)
.Range("A1") = "Wbook opened at:"
.Range("A2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Sheets(1)
.Range("B1") = "Last closed at:"
.Range("B2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

hth

Geoff K

"will07" wrote:

Hello All,

Is it possible to add some code into a file that will show the session time
(in a cell)that a file is open or has been used.

thanks


will07

Session Times
 
Geoff,

The code worked OK, however both times are current (the same). I was
thinking after I wrote in, it would be great to have a ticking clock in range
B1:B2 to let the user know how long the session is taking. The range A1:A2
(start of session) works great. I need to get the user thinking how long
he/she is spending on 1 job.

The history does not matter, and the session time need not be archived,
although it would help.

Thanks





"Geoff K" wrote:

try something like this

put this into your ThisWorkBook module
Private Sub Workbook_Open()
With Sheets(1)
.Range("A1") = "Wbook opened at:"
.Range("A2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Sheets(1)
.Range("B1") = "Last closed at:"
.Range("B2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

hth

Geoff K

"will07" wrote:

Hello All,

Is it possible to add some code into a file that will show the session time
(in a cell)that a file is open or has been used.

thanks



All times are GMT +1. The time now is 03:11 PM.

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