Is there any way to simplify these checkbox codes. Preferably into a single code somehow so that if I add sheets and add to the index, I don't have to go through and re-write half of the code??? I know that I could just add to the end of the code each time I add a sheet, but I'm trying to keep it organized for the next person that may come along to try to figure it out (or even myself after a few years... lol).
This example is just from my "test" report that I use for testing codes. A few of the real reports have upwards of 50-60 checkboxes... which becomes a major headache when modifying the code.
Code:
Private Sub CheckBox1_Click()
Sheets("1st Stg Impeller").Visible = CheckBox1.Value
Application.Run "IndexNumber"
End Sub
Private Sub CheckBox2_Click()
Sheets("2nd Stg Impeller").Visible = CheckBox2.Value
Application.Run "IndexNumber"
End Sub
Private Sub CheckBox3_Click()
Sheets("1st_2nd Stg Pinion").Visible = CheckBox3.Value
Application.Run "IndexNumber"
End Sub
Private Sub CheckBox4_Click()
Sheets("1st Stg Laby").Visible = CheckBox4.Value
Application.Run "IndexNumber"
End Sub
Private Sub CheckBox5_Click()
Sheets("2nd Stg Laby").Visible = CheckBox5.Value
Application.Run "IndexNumber"
End Sub
Private Sub CheckBox6_Click()
Sheets("1st Stg Tiebolt_Nut").Visible = CheckBox6.Value
Application.Run "IndexNumber"
End Sub
Private Sub CheckBox7_Click()
Dim i As Integer
For i = 1 To 6
ActiveSheet.OLEObjects("CheckBox" & i).Object.Value = ActiveSheet.CheckBox7.Value
Next i
End Sub
This example is just from my "test" report that I use for testing codes. A few of the real reports have upwards of 50-60 checkboxes... which becomes a major headache when modifying the code.