mercredi 19 août 2020

use checkbox to hide/unhide rows based on cell value

Using VBA in excel, trying to understand how I can use a checkbox to hide/unhide any row that has a specific value in a specific column. My VBA skills are getting better more I practice but I am still not good with loops just yet. Appreciate any help you can provide. Here is what I have so far.

Private Sub CkBx_ShowAllRecords_Click()
If Me.CkBx_ShowAllRecords = True Then
 For Each Row In Range("Table1").ListObject.ListColumns
    If Row.Cells(1, "column5").Value = "Submission Complete" Then
    Application.EntireRow.Visible=True
Next
End if
End Sub

Additionally when I uncheck the box I would want all rows where column 5 cell value equals "submission complete" would be hidden (just the opposite of what I put above when I check the box control).




Aucun commentaire:

Enregistrer un commentaire