I have these two codes and separately they work perfectly. However if I run the "Add more parts" code then try to alter the index by checking/unchecking boxes, the index code throws an error regarding the OLEObjects. Is there a way to tell the index code to ignore any sheets containing the name "Additional Parts (#)"???? Or someway else to get it to work together without modifying the index numbering?
Add more parts code:
Index Code:
And just incase you need it, here is the index numbering code:
Thanks in advance!
Add more parts code:
Code:
Sub AddMoreParts()
Sheets.Add Type:= _
"S:\SERVICE\Shop Teardown Reports\Teardown Templates\Additional Parts Template.xlt"
ActiveSheet.Move after:=Worksheets(Worksheets.Count)
End Sub
Index Code:
Code:
Private Sub CheckBox1_Click()
Dim i As Integer
For i = 2 To 25
ActiveSheet.OLEObjects("CheckBox" & i).Object.Value = ActiveSheet.CheckBox1.Value
Next i
Application.Run "IndexNumber"
End Sub
Private Sub CheckBox2_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox3_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox4_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox5_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox6_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox7_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox8_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox9_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox10_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox11_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox12_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox13_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox14_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox15_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox16_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox17_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox18_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox19_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox20_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox21_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox22_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox23_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox24_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub CheckBox25_Click()
Call Chkbox
Run ("IndexNumber")
End Sub
Private Sub Chkbox()
For i = 6 To ActiveWorkbook.Worksheets.Count
x = (i - 4)
Sheets(i).Visible = ActiveSheet.OLEObjects("Checkbox" & x).Object.Value
Next
End Sub
And just incase you need it, here is the index numbering code:
Code:
Sub IndexNumber()
Dim lx As Long
Dim sIndex As String
Dim sIndexStartRange As String
Dim lVisibleCount As Long
sIndex = "Index"
sIndexStartRange = "A7"
Worksheets(sIndex).Range("A7:A100").Cells.ClearContents
With Worksheets(sIndex).Range("A7")
For lx = 1 To Worksheets.Count
Select Case Worksheets(lx).Name
Case Else
If Worksheets(lx).Visible = True Then
lVisibleCount = lVisibleCount + 1
End If
If Worksheets(lx).Visible = True Then .Offset(lx - 1, 0) = lVisibleCount
End Select
Next
End With
End Sub
Thanks in advance!