Check box pop us message question

Chris Hoek

New Member
Joined
May 28, 2015
Messages
18
Office Version
  1. 365
Platform
  1. Windows
I want a popup message to appear when a box is checked, but I don't want the message to appear again when that same check box is clicked again to uncheck it.

I'm currently running this code:

Sub CheckBox582_Click()
rsp = MsgBox("Please provide reason for rejection via email or in the comments section below.", vbOKCancel)
If rsp = vbOK Then
Else
MsgBox ("Cancel button")
End If
End Sub


It works perfectly except I don't want the popup message to appear when the check box is unchecked.

Can someone please point me in the right direction?

Thanks a million in advance.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
just check the checkbox checked value it should be a boolean property called Value or Checked...

Code:
[COLOR=#333333][FONT=Verdana]Sub CheckBox582_Click()
[/FONT][/COLOR]    If CheckBox582.Checked Then
         'your code
    End If
End Sub

Also I forget if the checked value changes before or after the click event so just add a Not if this is wrong.
 
Last edited:
Upvote 0
Untested, but try adding this as the 1st line of code
Code:
If Not CheckBox582 Then Exit Sub
 
Upvote 0
I appreciate the assistance, however after trying multiple combinations of everything both of you suggested, I can't seem to get it to work properly.

This always seems to happen when I'm in a hurry, I'm probably missing something. I've simplified it a little bit to this code:

Sub CheckBox582_Click()
rsp = MsgBox("Please provide reason for rejection via email or in the comments section below.", vbOKCancel)
If rsp = vbOK Then
End If
End Sub

I'm still getting the popup message when I uncheck the box.
 
Upvote 0
This works for me, with both a userform Checkbox & an ActiveX checkbox on a sheet
Code:
Sub CheckBox582_Click()
   If Not CheckBox582 Then Exit Sub
   rsp = MsgBox("Please provide reason for rejection via email or in the comments section below.", vbOKCancel)
   If rsp = vbOK Then
   Else
      MsgBox ("Cancel button")
   End If
End Sub
 
Upvote 0
in my code example, the correct property should be Value, not Checked based on the following post... here i will paste it for you...

Code:
Sub CheckBox582_Click()
    If CheckBox582 Then
        rsp = MsgBox("Please provide reason for rejection via email or in the comments section below.", vbOKCancel)
        If rsp = vbOK Then
            [COLOR=#008000]'run code that applies to user clicking ok[/COLOR]
        End If
    End If 
End Sub

this code will work if the value is already changed before the click event runs. So you must debug and determine that. If code works then no need to edit.
 
Last edited:
Upvote 0
I did that exactly and there is no popup message when checking or unchecking it now.
 
Upvote 0
put a breakpoint and see the result of this ...

Code:
[COLOR=#333333]If CheckBox582 Then

...when u check and uncheck. When you debug it the problem will be obvious[/COLOR]
 
Last edited:
Upvote 0
Thank you everyone.

I couldn't get any of that to do exactly what I needed it to. I don't know enough about breakpoints or debugging to figure it out and I ran out of time to keep trying different things. I did a little more searching and found this which worked:

Assigning the action:

Sub Checkbox_Command()
Dim cb
For Each cb In ActiveSheet.CheckBoxes
If Not Application.Intersect(cb.TopLeftCell, _
ActiveSheet.Range("R:R")) Is Nothing Then
cb.OnAction = "Sheet1.Reject_Reason"


End If
Next cb
End Sub

In the sheet code module:

Sub Reject_Reason()
Dim cb As Checkbox
Set cb = Me.CheckBoxes(Application.Caller)
If cb.Value = 1 Then
MsgBox "Please provide reason for rejection via email or in the comments section below."
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

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