I tried putting together a code for a checkbox in Sheet "Budget" which will unhide 4 rows on Sheet "Vendor Cost". When the checkbox is ticked, it should unhide the row on Sheet "Vendor Cost" which contains value "1000L" on column A and 3 more rows underneath it (no value on column A). I can't specify row numbers because there is an option in the sheet to add more rows so column A entries may change row address.
Here's what I have so far but not working.
Private Sub CheckBox1_Click() Dim c As Range
Application.ScreenUpdating = False
With ThisWorkbook.Worksheets("Budget")
For Each c In ThisWorkbook.Worksheets("Vendor Cost").Range("A4:A1000" & ThisWorkbook.Worksheets("Vendor Cost").Cells(.Rows.Count, "A").End(xlUp).Row).Cells
If IsError(c) Then c.Value2 = "1000L" 'Hides errors as well
c.Resize(4).EntireRow.Hidden = (c.Value = "1000L" And ThisWorkbook.Worksheets("Vendor Cost").CheckBox1.Value) = False
Next
End With
Application.ScreenUpdating = True
End Sub
Can anyone take a look and teach me where I'm wrong? Please and thank you.
Here's what I have so far but not working.
Private Sub CheckBox1_Click() Dim c As Range
Application.ScreenUpdating = False
With ThisWorkbook.Worksheets("Budget")
For Each c In ThisWorkbook.Worksheets("Vendor Cost").Range("A4:A1000" & ThisWorkbook.Worksheets("Vendor Cost").Cells(.Rows.Count, "A").End(xlUp).Row).Cells
If IsError(c) Then c.Value2 = "1000L" 'Hides errors as well
c.Resize(4).EntireRow.Hidden = (c.Value = "1000L" And ThisWorkbook.Worksheets("Vendor Cost").CheckBox1.Value) = False
Next
End With
Application.ScreenUpdating = True
End Sub
Can anyone take a look and teach me where I'm wrong? Please and thank you.