Message box control

rjplante

Well-known Member
Joined
Oct 31, 2008
Messages
572
Office Version
  1. 365
Platform
  1. Windows
I have the code listed below which is being called when a cell changes from 'no' to 'yes'. When the message box pops up and I click 'no', the message box chimes and displays again and I have to click it twice to get it to go away. I am running Excel 2007. What is causing this to do this? This macro is located in a worksheet code window and not a global workbook module. It needs to be there due to the fact that the code that monitors the change from 'no' to 'yes' is also in this sheet code window. Thanks for any ideas as I am at a loos on where to go from here.

Robert

-------------------------------

Sub MSTS_Update()

Application.EnableEvents = False

i = MsgBox("Do you want to update the Master Stability Tracking Sheet?", vbYesNo + vbExclamation + vbDefaultButton2)

If i = 7 Then 'NO
Application.EnableEvents = True
Exit Sub

ElseIf i = 6 Then 'YES
Application.ScreenUpdating = False

'rest of macro here

End If
Application.EnableEvents = True

End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
How is that code being triggered?

Is MSTS a control of some sort?
 
Upvote 0
It is triggered with the code below. When the value in cell BE7 changes from no to yes it launches the macro.

-----------------------
Code:
Private Sub Worksheet_Calculate()

If Range("BE7").Value = "YES" Then Call MSTS_Update

End Sub

Here is the macro called:

Code:
Sub MSTS_Update()

Application.EnableEvents = False

i = MsgBox("Do you want to update the Master Stability Tracking Sheet?", vbYesNo + vbExclamation + vbDefaultButton2)

If i = 7 Then 'NO
Application.EnableEvents = True
Exit Sub

ElseIf i = 6 Then 'YES
Application.ScreenUpdating = False

'rest of macro here

End If
Application.EnableEvents = True

End Sub
 
Last edited:
Upvote 0
So the code is trigggered whenever the worksheet is calculated?

Is that definitely what you want to do?
 
Upvote 0
I would like the code to be triggered whenever the cell BE7 is changed not the whole worksheet.
 
Upvote 0
Robert

Is that cell changed by formula or manual entry?

If it was a formula then you would probably use the Calculate event but if it's manually then you would normally use the Change event.
 
Upvote 0

Forum statistics

Threads
1,218,694
Messages
6,143,949
Members
450,517
Latest member
Rovex

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