-
Solved: Message Box On Open
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.
[VBA]
Private Sub Workbook_Open()
MsgBox ("This File Was Created By John Smith. (Updated 4/24/2006)")
End Sub
[/VBA]
How do you count the amount of times the file is opened?
Thanks
Gary
-
[vba]
'-----------------------------------------------------------------
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
[/vba]
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
-
Thanks XLD works great. Please mark this one solved.
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules