Hide only checkboxes with vba, not columns or rows

Last Edited By Krjb Donovan
Last Updated: Mar 05, 2014 09:40 PM GMT


Checkbox Example with Code

Hi Ken! I'm working in Excel 2007 and I'm trying to show or hide checkboxes based on whether or not another checkbox has been checkd. Main checkbox is labeled Fish, secondary checkboxes are labeled Catfish and Goldfish. Right now the VBA code is hiding both the checkboxes and the column. I don't want to hide the column, only the checkboxes. Is there a way to do this? If Fish is checked, I want the other two to be visible. If not checked, not visible.



Something like the following should work:

Sub hideunhide()

   If ActiveSheet.CheckBoxes("Check Box 1").Value = 1 Then
       ActiveSheet.CheckBoxes("Check Box 2").Visible = True
       ActiveSheet.CheckBoxes("Check Box 3").Visible = True
       ActiveSheet.CheckBoxes("Check Box 2").Visible = False
       ActiveSheet.CheckBoxes("Check Box 3").Visible = False
   End If

End Sub


©2024 eLuminary LLC. All rights reserved.