Msgbox to pop-up based on Checkbox's value

karti1986

Board Regular
Joined
Jun 24, 2014
Messages
60
Hi All

I did check this thread related to my question here.. (https://www.mrexcel.com/forum/excel...e-vba-look-checkbox-if-its-checked-not-3.html)

I have tried the below option I have tried and also tried few other things mentioned in the above thread, nothing seem to work for me.

My check box is through Developer -> Controls -> Form Controls -> Check Box

If ActiveSheet.CheckBoxes("TechTowerChk").Value = xlOn Then
MsgBox "Work with Person X"
End If

Is there anything im doing wrong here. Thanks in Advance!

Regards
KG
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Here's how I usually "read" checkboxes:

Code:
        'Store the recently activated checkbox as an object
        Dim activeBox As CheckBox
        Set activeBox = ws.Shapes("TechTowerChk").OLEFormat.Object

        'If it is checked...
        If activeBox.value = 1 Then

        MsgBox("Work with Person X")
  
        Else

        'What happens if NOT checked...

        End If
 
Last edited:
Upvote 0
Hi,
your code worked ok for me

Code:
Sub TechTowerChk_Click()
    If ActiveSheet.CheckBoxes("TechTowerChk").Value = xlOn Then
        MsgBox "Work with Person X"
    End If
End Sub


Share how is code called in your application.


Dave
 
Last edited:
Upvote 0
This is all you should need:
Code:
If ActiveSheet.TechTowerChk.Value = True Then MsgBox "Work with Person X"
 
Last edited:
Upvote 0
I see now you are working with Form controls not activex controls.
So maybe they work different.
I see your getting lots of help. So I will move on.
 
Upvote 0
This is all you should need:
Code:
If ActiveSheet.TechTowerChk.Value = True Then MsgBox "Work with Person X"


Tried this now, didnt work. Please look into my whole code which im replying to my original Code. Hope it gives a little more clarity

Regards
KG
 
Upvote 0
Hi,
your code worked ok for me

Code:
Sub TechTowerChk_Click()
    If ActiveSheet.CheckBoxes("TechTowerChk").Value = xlOn Then
        MsgBox "Work with Person X"
    End If
End Sub


Share how is code called in your application.


Dave

Thanks! Well here is my code... im not sure what's wrong here

Private Sub Worksheet_Change(ByVal Target As Range)

'Checkbox checks based on

If Range("F6").Value = "Simple" Then
ActiveSheet.CheckBoxes("CustomerTechTowerChk").Value = xlOff
ActiveSheet.CheckBoxes("CustomerTechTowerChk").Enabled = False
End If

If Range("F6").Value = "Medium" Then
ActiveSheet.CheckBoxes("CustomerTechTowerChk").Value = xlOff
ActiveSheet.CheckBoxes("CustomerTechTowerChk").Enabled = False
End If

If Range("F6").Value = "Complex" Then

ActiveSheet.CheckBoxes("CustomerTechTowerChk").Value = xlOff
ActiveSheet.CheckBoxes("CustomerTechTowerChk").Enabled = False
End If

If Range("F6").Value = "Customized" Then
ActiveSheet.CheckBoxes("CustomerTechTowerChk").Enabled = True
End If

'This is where it allows to have a user input as well as formula

Dim DrpDnCl As Range
Set DrpDnCl = Range("F6") '<- Cell with the dropdown
Set mimsptcvg = Range("G14") '<- Cell that will be input or formula

If Target.Address = DrpDnCl.Address Then
On Error GoTo handlr
Application.EnableEvents = False
If DrpDnCl.Value = "Customized" Then
mimsptcvg.ClearContents

Else
mimsptcvg.Formula = "=IF(F6=""Simple"",""24*7"",IF(F6=""Medium"",""24*7"",IF(F6=""Complex"",""24*7"","""")))" '<- Formula to go in that cell
End If
End If


If ActiveSheet.CheckBoxes("CustomerTechTowerChk").Value = xlOn Then
MsgBox "Work with Person X"
End If


handlr:
Application.EnableEvents = True

End Sub
 
Upvote 0
Now I even tried, assigning those checkbox's output to a cell(GK11). Through rightclick checkbox and format.. Checking the check box will change the value to TRUE

If Range("GK11").Value = "TRUE" Then
Application.EnableEvents = True
MsgBox ("Why dont you work???")
End If

even this wont work. Is this something to do with Enable events = FALSE earlier in the code?

Regards
KG
 
Upvote 0

Forum statistics

Threads
1,216,098
Messages
6,128,812
Members
449,468
Latest member
AGreen17

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