ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Count the times a file is opened (https://www.excelbanter.com/excel-programming/379903-count-times-file-opened.html)

[email protected]

Count the times a file is opened
 
Can Excel count the number of times a file has been opened and place
the count in cell A1? I thought I had a solution when someone
suggested the following response, but I couldn't get it to execute.
Does anyone else have any suggestions? Thanks. Michael

You could use a Workbook_Open event thus

Private Sub Workbook_Open()
Worksheets("Tracker").Range("A1").Value = _
Worksheets("Tracker").Range("A1").Value + 1
End Sub


This put the value in A1 on a sheet called tracker, remember users have
a
habit of changing or deleting stuff, so you may want to hide the
worksheet.
To implement, right click on the small Excel icon for the workbook and
select view code. Paste the code here, save and close


NickHK

Count the times a file is opened
 
Michael,
Is the code in the correct place ?
On the ThisWorkbook module.

And are events enabled ?
In the Immediate panes, what does this return
?Application.EnableEvents

NickHK

wrote in message
oups.com...
Can Excel count the number of times a file has been opened and place
the count in cell A1? I thought I had a solution when someone
suggested the following response, but I couldn't get it to execute.
Does anyone else have any suggestions? Thanks. Michael

You could use a Workbook_Open event thus

Private Sub Workbook_Open()
Worksheets("Tracker").Range("A1").Value = _
Worksheets("Tracker").Range("A1").Value + 1
End Sub


This put the value in A1 on a sheet called tracker, remember users have
a
habit of changing or deleting stuff, so you may want to hide the
worksheet.
To implement, right click on the small Excel icon for the workbook and
select view code. Paste the code here, save and close




[email protected]

Count the times a file is opened
 
Nick. Thanks for your response, especially since I believe it was from
you that I got the macro. I can get it to work on a blank workbook,
but I have a project that I've been working on for sometime, on which
it doesn't want to work. I wonder if it is because I have a "splash."
I have it in the ThisWorkbook module, but I also have a macro for the
splash there. Following is a copy. Is it wrong to have both there.
As you can tell, I'm still pretty new at macros. Thanks again for your
help. Michael

Private Sub Workbook_Open()
UserForm1.Show
End Sub

Private Sub Workbook_Open()
Worksheets("Instructions").Range("M1").Value = _
Worksheets("Instructions").Range("M1").Value + 1
End Sub


NickHK wrote:
Michael,
Is the code in the correct place ?
On the ThisWorkbook module.

And are events enabled ?
In the Immediate panes, what does this return
?Application.EnableEvents

NickHK

wrote in message
oups.com...
Can Excel count the number of times a file has been opened and place
the count in cell A1? I thought I had a solution when someone
suggested the following response, but I couldn't get it to execute.
Does anyone else have any suggestions? Thanks. Michael

You could use a Workbook_Open event thus

Private Sub Workbook_Open()
Worksheets("Tracker").Range("A1").Value = _
Worksheets("Tracker").Range("A1").Value + 1
End Sub


This put the value in A1 on a sheet called tracker, remember users have
a
habit of changing or deleting stuff, so you may want to hide the
worksheet.
To implement, right click on the small Excel icon for the workbook and
select view code. Paste the code here, save and close



[email protected]

Count the times a file is opened
 
Nick,

Success at last. I combined the macro for counting with the "splash"
macro to create a single sub routine. Both work perfectly together.
Thanks so very much for your help.

Michael

NickHK wrote:
Michael,
Is the code in the correct place ?
On the ThisWorkbook module.

And are events enabled ?
In the Immediate panes, what does this return
?Application.EnableEvents

NickHK

wrote in message
oups.com...
Can Excel count the number of times a file has been opened and place
the count in cell A1? I thought I had a solution when someone
suggested the following response, but I couldn't get it to execute.
Does anyone else have any suggestions? Thanks. Michael

You could use a Workbook_Open event thus

Private Sub Workbook_Open()
Worksheets("Tracker").Range("A1").Value = _
Worksheets("Tracker").Range("A1").Value + 1
End Sub


This put the value in A1 on a sheet called tracker, remember users have
a
habit of changing or deleting stuff, so you may want to hide the
worksheet.
To implement, right click on the small Excel icon for the workbook and
select view code. Paste the code here, save and close



NickHK

Count the times a file is opened
 
I am surprised that you did not get an error of "ambiguous name", as you
have 2 routine with the same name.
Just combine them together:

Private Sub Workbook_Open()
Worksheets("Instructions").Range("M1").Value = _
Worksheets("Instructions").Range("M1").Value + 1
UserForm1.Show
End Sub

NickHK

wrote in message
oups.com...
Nick. Thanks for your response, especially since I believe it was from
you that I got the macro. I can get it to work on a blank workbook,
but I have a project that I've been working on for sometime, on which
it doesn't want to work. I wonder if it is because I have a "splash."
I have it in the ThisWorkbook module, but I also have a macro for the
splash there. Following is a copy. Is it wrong to have both there.
As you can tell, I'm still pretty new at macros. Thanks again for your
help. Michael

Private Sub Workbook_Open()
UserForm1.Show
End Sub

Private Sub Workbook_Open()
Worksheets("Instructions").Range("M1").Value = _
Worksheets("Instructions").Range("M1").Value + 1
End Sub


NickHK wrote:
Michael,
Is the code in the correct place ?
On the ThisWorkbook module.

And are events enabled ?
In the Immediate panes, what does this return
?Application.EnableEvents

NickHK

wrote in message
oups.com...
Can Excel count the number of times a file has been opened and place
the count in cell A1? I thought I had a solution when someone
suggested the following response, but I couldn't get it to execute.
Does anyone else have any suggestions? Thanks. Michael

You could use a Workbook_Open event thus

Private Sub Workbook_Open()
Worksheets("Tracker").Range("A1").Value = _
Worksheets("Tracker").Range("A1").Value + 1
End Sub


This put the value in A1 on a sheet called tracker, remember users

have
a
habit of changing or deleting stuff, so you may want to hide the
worksheet.
To implement, right click on the small Excel icon for the workbook and
select view code. Paste the code here, save and close






All times are GMT +1. The time now is 02:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com