Counter for Number of times a document is opened


Posted by Scott Lancaster on December 17, 2001 7:47 PM

Hi,

I am using Excel 97, and i am wondering if their is anyway that you can have a cell automatically increment each time the sheet is opened?

Could you also please email any answers to slancaster@gates.com

Thanks,

Scott Lancaster
MIS Tech-Support Co-Ordinator
Gates Australia Pty Ltd.



Posted by DaK on December 17, 2001 9:05 PM

Put this code on the worksheet you want to count.

Private Sub Worksheet_Activate()
'Count the number of times this sheet get activated

On Error Resume Next

activecount

End Sub

Put this in a module

Public Sub activecount()
'Count the number of times the sheet is activated.

Dim x As Integer

x = Sheets("Sheet1").Range("a1") 'Substitute your sheet name and desired range

Range("a1") = 1 'Substitute your range again

Range("a1") = x + 1 'And substitute your range again
x = x + 1


End Sub


This should increment range a1 by one everytime the sheet is activated.

DaK