I'm having some issues with some VBA code. I've got a checkbox list and a button at the bottom that hides all of the rows/checkboxes that are not selected. The problem is that when I hit the box to view all again, the checkboxes are then all piled on top of each other rather than where they were. Here's the code I have to hide/view the rows and checkboxes:
And...
Is there any way to keep the checkboxes locked in place when hiding and making visible again?
Thanks
Code:
Sub HURows()
EndRow = 15
Set ws = ThisWorkbook.Worksheets("Project Parameters")
Range("B11").Select
With ws
For RowCnt = 1 To EndRow
If ActiveCell.Value = False Then
ActiveCell.EntireRow.Hidden = True
For Each chkBox In ws.OLEObjects
If TypeName(chkBox.Object) = "Checkbox" & RowCnt Then
chkBox.Visible = False
End If
Next chkBox
Else
ActiveCell.EntireRow.Hidden = False
For Each chkBox In ws.OLEObjects
If TypeName(chkBox.Object) = "Checkbox" & RowCnt Then
chkBox.Visible = True
End If
Next chkBox
End If
ActiveCell.Offset(1, 0).Select
Next
End With
End Sub
Code:
Sub HUNRows()
EndRow = 15
Set ws = ThisWorkbook.Worksheets("Project Parameters")
Range("B11").Select
With ws
For RowCnt = 1 To EndRow
If ActiveCell.Value = True Then
ActiveCell.EntireRow.Hidden = False
For Each chkBox In ws.OLEObjects
If TypeName(chkBox.Object) = "Checkbox" & RowCnt Then
chkBox.Visible = True
End If
Next chkBox
Else
ActiveCell.EntireRow.Hidden = False
For Each chkBox In ws.OLEObjects
If TypeName(chkBox.Object) = "Checkbox" & RowCnt Then
chkBox.Visible = False
End If
Next chkBox
End If
ActiveCell.Offset(1, 0).Select
Next
End With
End Sub
Is there any way to keep the checkboxes locked in place when hiding and making visible again?
Thanks