PDA

View Full Version : Hiding and then Unhiding Rows on Excel sheet based on if a checkbox is unchecked?



imaloser223
05-28-2019, 05:02 PM
The first time I run the code it works perfectly I click the button the rows that should disapper, disappear, along with the checkbox and then I clicked the other button and both the row and the checkbox reappear.


Then the other times it will go on to hide the next row which had replaced the hidden row and this then just keeps on going....



For Each cb In ActiveSheet.OLEObjects
If TypeName(cb.Object) = "CheckBox" Then
If cb.Object.Value = False And cb.Visible = True Then
theRow = cb.TopLeftCell.row
MsgBox cb.TopLeftCell.row
cb.Visible = False
Rows(theRow).Hidden = True
'cb.Visible = False
End If
End If
Next cb
For Each cb In ActiveSheet.OLEObjects
If TypeName(cb.Object) = "CheckBox" Then
If cb.Visible = False Then
cb.Visible = True
End If
End If
Next cb
Rows.Hidden = False

Help Please!

p45cal
05-29-2019, 06:25 AM
Suppy a workbook please - save us the time to try (incorrectly) replicating your setup.