write at exceltoexplore@gmail.com : Report Automation|Dashboard in Excel| Provide Excel consulting through macro (VBA) automation |Financial Modeling | Ethical Hacking

Monday, 15 August 2011

Count the Number of times file open

This requirement came from one of forum
Assuming your counter in cell "F2"
Try below code in thisworkbook model
whenever you open the workbook this number will increase by one



 
Private Sub Workbook_Open()
Sheets("Sheet1").Range("F2").Value = Sheets("Sheet1").Range("F2").Value + 1
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
End Sub

No comments:

Post a Comment