The code below works great but I realized I have an issue that needs to be accounted for. If the cells in range "J9:J378" are false I want to hide those rows. This part works great. The true and false are set in each cell in column "J" based on a userform checkbox. The problem is I need to eliminate (set to empty) a quantity in range A9:A378 based on the cells in Range J9:J378 that are being hidden due to the value being False. The problem arises when the userform is reopened and the checkbox is unselected while quantities have been assigned prior to unclicking the checkbox. It still adds to all the totals in the estimation worksheet creating false labor time and material cost based on the quantities that are unneeded in column "A".
So what I want to do is
If any cells in range J9:J378 are false, hide all rows and change any values in A9:A378 to empty as long as they are the same cells with a value of false.
Thank you for any help in advance, this forum has been a great resource for me through my journey of learning VBA.
Public Sub AcceptButton_Click()
Dim cell As Range
Application.ScreenUpdating = False
For Each cell In Range("J9:J378")
If cell.Value = "False" Then
cell.EntireRow.Hidden = True
Else
cell.EntireRow.Hidden = False
End If
Next
Application.ScreenUpdating = True
Application.ScreenUpdating = False
For Each cell In Range("J385:J1666")
If cell.Value = "False" Then
cell.EntireRow.Hidden = True
Else
cell.EntireRow.Hidden = False
End If
Next
Application.ScreenUpdating = True
Me.Hide
End Sub
Bookmarks