PDA

View Full Version : Solved: How to see when was a workbook last time opened



PaSha
08-27-2008, 02:24 AM
Heloo guys...

i have a problem... hope someone can help me...

i have a workbook and some code behind... which activates it self when the day of month is the 1

but the problem is, what when the workbook won't open on the 1 in month for some reason, but on 2nd or 3th ??

how can i program it...
to see if the workbook was not opened on the 1st? but on the 2nd and i want that part of code to be performed???

:doh:

Kenneth Hobs
08-27-2008, 10:03 AM
Rather than check for the 1st, check that the month is not the same month as that entered in some cell or a file property. In other words, when you do the update, update the cell or file property value to that date.


Here is a method that you can adapt. Notice that it adds information to a hidden sheet named Log that is password protected. You can set it to the Open event easily enough. You can easily just use say A1 on sheet Log for what you need.


'VOG II,http://www.mrexcel.com/forum/showthread.php?p=1666961#post1666961
Private Sub Worksheet_Change(ByVal Target As Range)
Dim NR As Long
If Intersect(Target, Range("F15:F25")) Is Nothing Then Exit Sub
With Sheets("Log")
.Unprotect Password:="xyz"
NR = .Range("A" & Rows.Count).End(xlUp).Row + 1
.Range("A" & NR).Value = Target.Address(False, False)
.Range("B" & NR).Value = Now
.Range("C" & NR).Value = Environ("username")
.Protect Password:="xyz"
End With
End Sub

PaSha
08-28-2008, 12:58 AM
Hej man :D thanks a lot...

that was what i was searching for... :friends: you're the best...

:banghead: i just couldn't get to that idea ... cool

case solved :)