VBA Pop-up Frequency

rhmkrmi

Active Member
Joined
Aug 17, 2012
Messages
308
Hi there,

I have a code as follows and I am wondering if there is a way I can control the popping up.
I mean can I say pop-up only once when the user enters the sheet or will it have to always pop up every time the user enters the sheet:

Private Sub Worksheet_Activate()
MsgBox "Check the calculation"

Thank you.
 

Some videos you may like

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
20,052
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
You could use a trigger cell, in this case "A1"

VBA Code:
Private Sub Worksheet_Activate()
If Cells(1, 1).Value = 1 Then Exit Sub
MsgBox "Check the calculation"
Cells(1, 1).Value = 1
End Sub

You would then need to clear the cell when the workbook closes

VBA Code:
Private Sub workbook_beforeclose()
Sheets("Sheet1").Cells(1, 1).Value = "" 'change sheet name to suit
End Sub
 

rhmkrmi

Active Member
Joined
Aug 17, 2012
Messages
308
Thanks.

So there is no code that I can use without using a trigger cell to specify the number of times, like Do Until x = 1?
 

davesexcel

Well-known Member
Joined
Feb 26, 2006
Messages
1,089
You can place the date into a cell, then when you active the sheet, it will check if that cell =todays date.

VBA Code:
Private Sub Worksheet_Activate()

    If Range("A1") <> Date Then
        MsgBox "Something something"
        Range("A1") = Date
    End If
End Sub
 

rhmkrmi

Active Member
Joined
Aug 17, 2012
Messages
308

ADVERTISEMENT

I have another code as:

Private Sub Workbook_Open()
MsgBox "Check all sheets"
End Sub

It seems to interfere with the codes suggested above and gives me this message:

1600043513331.png


Thanks.
 

rhmkrmi

Active Member
Joined
Aug 17, 2012
Messages
308
I could not get any of the solutions to work.
Could you please help with some more details?

Thank you.
 

rhmkrmi

Active Member
Joined
Aug 17, 2012
Messages
308

ADVERTISEMENT

Can something like "If already prompted' be built into it? For example:

Private Sub Worksheet_Activate()
Static alreadyPrompted As Boolean
If alreadyPrompted Then Exit Sub
MsgBox "Check the calculation"
alreadyPrompted = True
End Sub
 

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
8,187
Office Version
  1. 2016
Platform
  1. Windows
Can something like "If already prompted' be built into it? For example:

Private Sub Worksheet_Activate()
Static alreadyPrompted As Boolean
If alreadyPrompted Then Exit Sub
MsgBox "Check the calculation"
alreadyPrompted = True
End Sub
Yes that code should work for prompting the user only the first time the sheet is activated.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,872
Messages
5,627,389
Members
416,245
Latest member
Xterminat

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
Top