I have an excel 2010 workbook that include 3 sheets. The first sheet allows the user to select via checkbox the categories that will appear on the second sheet, and the second sheet will then allow the user to select from options within the categories limited by the first sheet to determine the output on the third sheet.
When the user selects certain checkboxes on the first sheet, there are associated cells in the second sheet that populate with a true or false value. The present script then runs via a controlbutton to hide the rows with a false value on the second sheet. There are two rows with no checkboxes between each category, one is blank, and the other is the next category title, so I have 4 rows of options with a checkbox assigned to each row, then 1 blank row, a title row, then a series of 4 more options with checkboxes, and so on for about 75 rows.
My problem is that while rows 10-13 are associated with checkboxes 1-4, checkbox 5 doesn't appear until row 16 because of the 2 'unselectable' rows between options, so I can't figure out how to loop the object hide to make the unnecessary checkboxes invisible. Right now I'm building an If statement for each row/checkbox, and it's slowly driving me insane. My code looks like this:
Does anyone know how I could make a loop that would determine whether to hide checkboxes 1-4 based on the visibility of rows 10-13, then skip rows 14 and 15, then check checkboxes 5-8 based on rows 16-19, then skip rows 20 and 21, and so on? There are not always 4 rows in a category, sometimes there are 3 or 5, which could add another level of difficulty. Please help so I don't have to put in 50 If statements!
Let me know if you need any further explanation, though I feel like I may have overexplained a bit. Thank you!
When the user selects certain checkboxes on the first sheet, there are associated cells in the second sheet that populate with a true or false value. The present script then runs via a controlbutton to hide the rows with a false value on the second sheet. There are two rows with no checkboxes between each category, one is blank, and the other is the next category title, so I have 4 rows of options with a checkbox assigned to each row, then 1 blank row, a title row, then a series of 4 more options with checkboxes, and so on for about 75 rows.
My problem is that while rows 10-13 are associated with checkboxes 1-4, checkbox 5 doesn't appear until row 16 because of the 2 'unselectable' rows between options, so I can't figure out how to loop the object hide to make the unnecessary checkboxes invisible. Right now I'm building an If statement for each row/checkbox, and it's slowly driving me insane. My code looks like this:
Code:
If ActiveSheet.Rows("10").Hidden = True Then
ActiveSheet.CheckBox1.Visible = False
Else: ActiveSheet.CheckBox1.Visible = True
End If
If ActiveSheet.Rows("11").Hidden = True Then
ActiveSheet.CheckBox2.Visible = False
Else: ActiveSheet.CheckBox2.Visible = True
End If
If ActiveSheet.Rows("12").Hidden = True Then
ActiveSheet.CheckBox3.Visible = False
Else: ActiveSheet.CheckBox3.Visible = True
End If
If ActiveSheet.Rows("13").Hidden = True Then
ActiveSheet.CheckBox4.Visible = False
Else: ActiveSheet.CheckBox4.Visible = True
End If
If ActiveSheet.Rows("16").Hidden = True Then
ActiveSheet.CheckBox5.Visible = False
Else: ActiveSheet.CheckBox5.Visible = True
End If
Does anyone know how I could make a loop that would determine whether to hide checkboxes 1-4 based on the visibility of rows 10-13, then skip rows 14 and 15, then check checkboxes 5-8 based on rows 16-19, then skip rows 20 and 21, and so on? There are not always 4 rows in a category, sometimes there are 3 or 5, which could add another level of difficulty. Please help so I don't have to put in 50 If statements!
Let me know if you need any further explanation, though I feel like I may have overexplained a bit. Thank you!