How to get a message box to only appear once

scotthannaford1973

Board Regular
Joined
Sep 27, 2017
Messages
111
Office Version
  1. 2010
Platform
  1. Windows
Hi

I have a very basic message box that appears when someone goes to a particular worksheet; however I only want it to appear once, so if someone clicks onto another worksheet and then back to the one with the message box, it doesn't reappear. Would be grateful for assistance :)



Private Sub Worksheet_Activate()

msgbox "Do Not Sort This Worklist"

End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Do you mean once ever, or once each time the workbook is used, or something else?
 
Upvote 0
Do you mean once ever, or once each time the workbook is used, or something else?
good question i.e.

each time the workbook opens and the user goes to the worksheet x, the message pops up, they then go to another worksheet and back to worksheet x, the message does not reappear. However, if they close and reopen the workbook, I want the single pop up again.
 
Upvote 0
In that case you could use a static variable:

Code:
Private Sub Worksheet_Activate()
Static counter as long
if counter = 0 then 
msgbox "Do Not Sort This Worklist"
counter = 1
end if
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,338
Messages
6,124,343
Members
449,155
Latest member
ravioli44

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