How many times a spreadsheet is opened

nathank

New Member
Joined
Sep 11, 2002
Messages
14
Hello,

We have excel spreadsheets that we have to update every year due to wage changes. There are thousands of them. I was hoping to be able to designate a cell eg A400 to count how many times the file has been opened. If it is 0 I am not going to update.

Regards

Nathan Kennedy
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
right-click on the excel icon to the left of the word 'file' on the left of the menu bar. select 'view code'. double-click on 'this workbook', and place the following code into the workbook's object window:

Private Sub Workbook_Open()
Range("A400").Value = Range("A400").Value + 1
ActiveWorkbook.Save
End Sub

this code will add one to the value in A400 each time the workbook is opened, and then save the workbook.

HTH
kevin
 
Upvote 0
you could further modify this code to give you a message upon opening:

Private Sub Workbook_Open()
Range("A400").Value = Range("A400").Value + 1
Times_Opened = Range("A400").Value
MsgBox ("This file has been opened " & Times_Opened & " times.")
ActiveWorkbook.Save
End Sub
 
Upvote 0
In an entirely 'groundhog day' moment - don't forget to protect the cell! Who can remember the link to ozgrid?

Paddy
 
Upvote 0
but if you protect the cell, won't that prevent the macro from running properly and editing the cell as it should?

kevin
 
Upvote 0
not if you used the "less than fool-proof" method of using data validation & setting the check to

=len(a400)=""

This will stop users overtyping the value ("protection" of sorts), while allowing the macro to do its thing...

Paddy
 
Upvote 0
i see what you are saying Paddy - good point

kevin
 
Upvote 0

Forum statistics

Threads
1,213,486
Messages
6,113,932
Members
448,533
Latest member
thietbibeboiwasaco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top