+ Reply to Thread
Results 1 to 2 of 2

RE: Count numbers of times workbook opened

Hybrid View

  1. #1
    Jim Thomlinson
    Guest

    RE: Count numbers of times workbook opened

    Normally I try not to shoot down a suggestion (just because it is different
    from how I would go about it does not make it wrong... just different) but in
    this case the code posted will cause problems.

    The code posted is intended to be placed in ThisWorkbook. But the reference
    is to A65500 which will be a problem as it will refer to cell 65,500 on
    whichever sheet might happen to be active at the time the book is opened.
    Next time it is opened it could be a different sheet. Also the cell is not
    hidden from the end user who could delete it (intentioanlly or otherwise).
    Also if a row is deleted or inserted on the sheet the value will be moved and
    now the value will be lost. here is how I would go about it...

    Create a new sheet called Variables (or whatever makes your heart go pitter
    patter). The only thing this sheet will be used for is holding values that
    the end user will never see.

    In Cell A1 on the sheet add Workbook Opened (we will put the number of times
    in Cell B1)

    Private Sub Workbook_Open()
    with sheets("Variables").range("B1")
    .Value = .Value +1
    msgbox "This book has been opened " & .Value & " times."
    end with
    sheets("Variables").visible = xlVeryHidden
    End Sub

    --
    HTH...

    Jim Thomlinson


    "excelent" wrote:

    > my best ges:
    >
    > Private Sub Workbook_Open()
    > MsgBox ("This file has been opened ") & [a65500] & " times"
    > [a65500] = [a65500] + 1
    > End Sub
    >


  2. #2
    excelent
    Guest

    RE: Count numbers of times workbook opened

    offcourse ir right Jim,- ges that 1 was too close to bedtime lol :-)


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1