View Full Version : Solved: Message Box On Open
zoom38
04-24-2006, 06:42 AM
Can a message box pop up every 10th time the file is open?? 15th time?? I did the easy part, here is my code, I can't figure this out.
Private Sub Workbook_Open()
MsgBox ("This File Was Created By John Smith. (Updated 4/24/2006)")
End Sub
How do you count the amount of times the file is opened?
Thanks
Gary
Bob Phillips
04-24-2006, 10:11 AM
'-----------------------------------------------------------------
Private Sub Workbook_Open()
'-----------------------------------------------------------------
Dim cOpen As Long
cOpen = 0 ' in case it doesn't already exist
On Error Resume Next
cOpen = Evaluate(ThisWorkbook.Names("OpenCount").RefersTo)
cOpen = cOpen + 1
If cOpen = 10 Then
MsgBox "10th time of opening"
cOpen = 0
End If
ThisWorkbook.Names.Add Name:="OpenCount", RefersTo:="=" & cOpen
End Sub
This is workbook event code.
To input this code, right click on the Excel icon on the worksheet
(or next to the File menu if you maximise your workbooks),
select View Code from the menu, and paste the code
zoom38
04-24-2006, 11:26 AM
Thanks XLD works great. Please mark this one solved.
Gary
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.