Message box control

rjplante

Active Member
Joined
Oct 31, 2008
Messages
489
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
 

Some videos you may like

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,219
Office Version
  1. 365
Platform
  1. Windows
How is that code being triggered?

Is MSTS a control of some sort?
 

rjplante

Active Member
Joined
Oct 31, 2008
Messages
489
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:

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,219
Office Version
  1. 365
Platform
  1. Windows
So the code is trigggered whenever the worksheet is calculated?

Is that definitely what you want to do?
 

rjplante

Active Member
Joined
Oct 31, 2008
Messages
489

ADVERTISEMENT

I would like the code to be triggered whenever the cell BE7 is changed not the whole worksheet.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,219
Office Version
  1. 365
Platform
  1. Windows
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,158
Messages
5,600,052
Members
414,357
Latest member
Gemma_R

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