Disable / automatic enable checkbox based on drop down reaponse

Adrienne80

New Member
Joined
May 10, 2020
Messages
7
Office Version
  1. 2019
Platform
  1. Windows
I’m pretty new to VBA, and I’ve tried several different codes to make my sheet work, but no luck. This is a quoting spreadsheet- in column V17 there are 4 options in a drop down- Prosurance, Assurance, Care, MI Only. Then I have 3 check boxes for additional options- cb1, cb2, cb3.
With the Prosurance option, all of the checkboxes should be automatically checked because they’re included. With Care, only cb1 should be enabled, the others disabled. MI only should have all Cb’s disabled, and assurance will have them all enabled. How can I code these to enable/disable/automatically select? I’m using the checkboxes in forms. Thanks in advance!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi and welcome to MrExcel!

Are the controls on the sheet or in a userform?
If they are on the sheet, I recommend that you use ActiveX controls.
You tell me.
 
Upvote 0
No I haven’t done them with ActiveX, I will try that. Will that need the code or can I set it in the controls?
 
Upvote 0
drop down
That is a Drop-down Lists created with a Data Validation List?

Ok, If the above is correct, then let's work with that and the useform checkboxes.

Put the following code in the sheet events:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Address(0, 0) = "V17" Then
    If Target.CountLarge > 1 Then Exit Sub
    If Target.Value = "" Then Exit Sub
    Select Case UCase(Target.Value)
      Case UCase("Prosurance")
        ActiveSheet.DrawingObjects("CheckBox1").Value = True
        ActiveSheet.DrawingObjects("CheckBox2").Value = True
        ActiveSheet.DrawingObjects("CheckBox3").Value = True
      Case UCase("Care")
        ActiveSheet.DrawingObjects("CheckBox1").Value = True
        ActiveSheet.DrawingObjects("CheckBox2").Value = False
        ActiveSheet.DrawingObjects("CheckBox3").Value = False
      Case UCase("MI Only")
        ActiveSheet.DrawingObjects("CheckBox1").Value = False
        ActiveSheet.DrawingObjects("CheckBox2").Value = False
        ActiveSheet.DrawingObjects("CheckBox3").Value = False
      Case UCase("Assurance")
        ActiveSheet.DrawingObjects("CheckBox1").Value = True
        ActiveSheet.DrawingObjects("CheckBox2").Value = True
        ActiveSheet.DrawingObjects("CheckBox3").Value = True
    End Select
  End If
End Sub

SHEET EVENT
Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.
 
Upvote 0
Yes, the drop down was created with the data validation list. Thanks so much, I’ll work on this in the morning and let you know how it works!
 
Upvote 0
That is a Drop-down Lists created with a Data Validation List?

Ok, If the above is correct, then let's work with that and the useform checkboxes.

Put the following code in the sheet events:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Address(0, 0) = "V17" Then
    If Target.CountLarge > 1 Then Exit Sub
    If Target.Value = "" Then Exit Sub
    Select Case UCase(Target.Value)
      Case UCase("Prosurance")
        ActiveSheet.DrawingObjects("CheckBox1").Value = True
        ActiveSheet.DrawingObjects("CheckBox2").Value = True
        ActiveSheet.DrawingObjects("CheckBox3").Value = True
      Case UCase("Care")
        ActiveSheet.DrawingObjects("CheckBox1").Value = True
        ActiveSheet.DrawingObjects("CheckBox2").Value = False
        ActiveSheet.DrawingObjects("CheckBox3").Value = False
      Case UCase("MI Only")
        ActiveSheet.DrawingObjects("CheckBox1").Value = False
        ActiveSheet.DrawingObjects("CheckBox2").Value = False
        ActiveSheet.DrawingObjects("CheckBox3").Value = False
      Case UCase("Assurance")
        ActiveSheet.DrawingObjects("CheckBox1").Value = True
        ActiveSheet.DrawingObjects("CheckBox2").Value = True
        ActiveSheet.DrawingObjects("CheckBox3").Value = True
    End Select
  End If
End Sub

SHEET EVENT
Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.

I'm back to working on this project - and this code DOES work, however, it only works for CheckBox 1,2, and 3 (there are 3 columns that the checkboxes are in). How do I make this code work for all checkboxes in the 3 different columns? Thank you
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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