question

gffffdhh-0172 avatar image
0 Votes"
gffffdhh-0172 asked Viorel-1 edited

How to hide Checkbox based on another cell value

Hi there,

I am creating a fillable excel form.

First question is located in Cell A2. It's a "Yes/No" question. If "Yes" is selected, I want further questions to appear below (including a checkbox). Otherwise if "No" or "Blank" further questions should remain hidden.

I have been able to hide the text/questions through formulas/conditional formatting, but how do I hide Checkboxes through Macros? I don't want to hide the entire row or column.

I am new at this and I have tried the following:

Sub CheckBox1 ( )
If Range("A2").Value = "Yes" Then
ActiveSheet.Shapes("CheckBox1").Visible = True
Else
ActiveSheet.Shapes("CheckBox1").Visible = False
End If
End Sub

Any guidance on the code/how to use Macros would be greatly appreciated!

office-vba-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered Viorel-1 edited

If it is an ActiveX checkbox, then go to Visual Basic, open the worksheet’s code and try adding this fragment:

 Private Sub Worksheet_Change(ByVal Target As Range)
     CheckBox1.Visible = Range("A2").Value = "Yes"
 End Sub

You can also handle the Worksheet_Activate event to set the initial visibility of controls.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.