Consulting

Results 1 to 2 of 2

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

  1. #1

    Hiding and then Unhiding Rows on Excel sheet based on if a checkbox is unchecked?

    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!

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Suppy a workbook please - save us the time to try (incorrectly) replicating your setup.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •