Open a message box if a worksheet is opened

M

MichaelRLanier

This is a 2 parter. I need a simple macro that states how many times
a worksheet has been opened today. I want the results to reflect in
cell A1. Then when A1>0 (as the sheet is opened), I need a message
box to open to display a simple sentence which can then be closed by
clicking an OK button. Here's thanking you in advance.

Michael
 
B

Bob Phillips

Private Sub Worksheet_Activate()

With Me.Range("A1")

If .Value > 0 Then

MsgBox "Sheet opened " & .Value & " times", vbOKOnly
.Value = .Value + 1
End If
End With
End Sub



'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top