Hi
do you mean to count how many times a file has been opened?. If yes you
may try the following code. Put this in your workbook module (not in a
standard module). It will increment the value in cell A1 on sheet1
Private Sub Workbook_Open()
with Worksheets("Sheet1").range("A1")
.Value = .Value + 1
end with
End Sub
Frank's code will actually count the number of times the workbook has been
opened AND saved.
If the workbook is closed without saving, then that change goes away.
If the workbook is "saveable" (not readonly), then you could save it as soon as
it opens:
A minor tweak to Frank's code:
Private Sub Workbook_Open()
with Worksheets("Sheet1").range("A1")
.Value = .Value + 1
end with
me.save
End Sub
If you can't save the workbook, then maybe you could use an external (accessible
(read/write) by all who open it to keep a counter.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.