Stack Exchange
Hide Checbox with rows when using VBA
In my excel file, I am hiding some rows with VBA code based on the value of a cell.
When Number of Properties= 6, all rows 72-82 are visible
image 1 rows 72-82

When Number of Properties =4 , only rows 72-78 are visible
image 2 rows 72-78

The VBA code that I am using is this:


ActiveSheet.Activate
If Target.Cells.Count <> 1 Then Exit Sub

If Not Application.Intersect(Range("U68"), Range(Target.Address)) Is Nothing Then

        Select Case Target.Value
        Case Is = "1": Rows("74:83").EntireRow.Hidden = True
                    
                        
        Case Is = "2": Rows("75:83").EntireRow.Hidden = True
                        Rows("72:75").EntireRow.Hidden = False
                        
        Case Is = "3": Rows("77:82").EntireRow.Hidden = True
                        Rows("72:77").EntireRow.Hidden = False
                        
        Case Is = "4": Rows("79:82").EntireRow.Hidden = True
                        Rows("72:79").EntireRow.Hidden = False
                        
       Case Is = "5": Rows("81:82").EntireRow.Hidden = True
                        Rows("72:81").EntireRow.Hidden = False
                        
       Case Is = "6":
                        Rows("72:83").EntireRow.Hidden = False
        End Select

End If



On these rows, I have also added some checkboxes.
As you can see, the checkboxes are not hiding when the rows are hiding. Instead they are overlapping. 
Is there any way I can update the VBA code to hide the checkboxes as well?
I have tried to use "Move and Size with cells" from Properties pane, but this is not working. My cells are still overlapping. 

Hi, could you try activating/deactivating the .Visible property of the checkbox? See the answer to this question for an example: https://stackoverflow.com/questions/25874335/make-checkboes-visible-and-invisible-when-a-checkbox-is-ticked-and-unticked

Depending on what you've named your CheckBoxes, try this:
    Select Case Target.Value
    Case Is = "1": 
        Rows("74:83").EntireRow.Hidden = True
        CheckBoxes("CheckBox1").Visible = False

And so on...
Replace "CheckBox1" with the name of the check box you want to hide                    
This uses the .Visible-property, as described in msdn docs
