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