VBA Pop-up Frequency

rhmkrmi

Active Member
Joined
Aug 17, 2012
Messages
336
Office Version
  1. 365
Platform
  1. Windows
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.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
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
 
Upvote 0
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?
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
I could not get any of the solutions to work.
Could you please help with some more details?

Thank you.
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,207
Members
448,554
Latest member
Gleisner2

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