VBA - Open Workbook Count

jaclynresendez

New Member
Joined
Jan 20, 2009
Messages
19
Hello All,

I'm trying to figure out how to get a count everytime my workbook is opened and to then place that number in a cell on the first sheet. Any suggestions would be greatly appreciated.

Thanks!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Welcome to the Board!

You can use something like this:

<font face=Tahoma><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Workbook_Open()<br>    Sheets("Sheet1").Range("A1").Value = Sheets("Sheet1").Range("A1").Value + 1<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Hope that helps,
 
Upvote 0
Actually, now that I've come back from lunch and back to my project I realize that it will not work since I am not saving the original workbook (I have it saving as a different file name and it's to use the open count in that title to made the file name unique).

Is there a code that actually counts the number of times a workbook is open in lieu of just adding one to an existing cell value?

Cheers!
 
Upvote 0
Actually, now that I've come back from lunch and back to my project I realize that it will not work since I am not saving the original workbook (I have it saving as a different file name and it's to use the open count in that title to made the file name unique).

Is there a code that actually counts the number of times a workbook is open in lieu of just adding one to an existing cell value?

Cheers!

If you're not saving the original I don't really see anyway to increment, unless you write to a text file.

Here's a good link from MVP Jon Peltier on how to do it: Using Text Files to Save and Retrieve Information in Microsoft Excel.

You might also consider creating a template, which will open with a 1 appended to the end of the file name.
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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