show/hide checkbox according to listbox

Masterofmayhem

New Member
Joined
Mar 10, 2011
Messages
3
Hi!

I'm new to the forum and VBA, so I need a bit of help.

Example:

A1 has a data validation list compirising of choices in cells B1,B2,B3. Easy.

C1 has a checkbox made through the developer tab. I want this to only show up if A1 has the value of cell B2.

This propably is simple, but as I have no previous experience of VBA, I am unable to modify any of the codes I have already found to suit my need.
Thanks for your assistance and time!
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Nevermind, figured it out... For anyone who needs to know this, this is how it goes:

1st: the checkbox needs to be created through ActiveX controls.

2nd: once the data validation list is done, the following code needs to be places in the worksheet code:

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Range("A1")

Case "a"
CheckBox2.Visible = True
CheckBox1.Visible = False

Case "b"
CheckBox2.Visible = False
CheckBox1.Visible = True

End Select
With Selection
CheckBox1.LinkedCell = "F2"
CheckBox2.LinkedCell = "F3"
End With
End Sub

In my worksheet the checkboxes are placed on top of each other, so that only one is used at any given time. In the full code, I added CheckBox#.Value = False to both data validation choices to always zero the checkboxes to unselected states.

If the checkboxes should link to the same cell, then the data can be told apart by adding a cell with double IF or an AND function. It is much simpler to have them linked to separate cells though =)
 
Upvote 0

Forum statistics

Threads
1,224,508
Messages
6,179,188
Members
452,893
Latest member
denay

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