How do I stop message box popping up twice?

vlwaring

New Member
Joined
May 20, 2014
Messages
15
I am new to VBA and I am using a code that will have a message box pop up if a value is less than another value. The box will appear if a check box is clicked, but if the value is less than the other specified value, I want the check box to uncheck itself. I know this is the reason why the message box comes up twice, but I don't know how to fix it.

Below is the my code:
Private Sub acpplan1_Click()
If TypeName(Sheet1.Range("AH64").Value) = "Error" Then Exit Sub
If Sheet1.Range("AH64").Value > Sheet4.Range("O11").Value Then
Application.EnableEvents = False
acpplan1.Value = False
Application.EnableEvents = True
MsgBox "The lowest minimum value plan offered does not meet the affordability test. Please reconsider employer contributions or choose alternative plans."
End If
End Sub

Any help would be much appreciated!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi and welcome to the board.
There are a couple ways to deal with that, likely the easiest is to simply test for the status of acpplan1 along with your error test at the beginning of the code.
Try amending this line:
If TypeName(Sheet1.Range("AH64").Value) = "Error" Then Exit Sub
To this:
If Not acpplan1 Or TypeName(Sheet1.Range("AH64").Value) = "Error" Then Exit Sub

Hope it helps.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,487
Messages
6,125,086
Members
449,206
Latest member
ralemanygarcia

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