Consulting

Results 1 to 3 of 3

Thread: How to see when was a workbook last time opened

  1. #1
    VBAX Contributor PaSha's Avatar
    Joined
    Nov 2007
    Location
    Slovenia
    Posts
    104
    Location

    How to see when was a workbook last time opened

    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???

    I like to help others... but sometimes i also need help ...

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    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

  3. #3
    VBAX Contributor PaSha's Avatar
    Joined
    Nov 2007
    Location
    Slovenia
    Posts
    104
    Location

    Exclamation :D

    Hey man thanks a lot...

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

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

    case solved
    I like to help others... but sometimes i also need help ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •