A
Ambassador
Running excel 2003 on two machines with different results. I have a form
checkbox to toggle visibility of "sheet2" listed below. It works on one and
I receive a error '9' subscript error on the machine i actually need it to
run on.
Sub CheckBox2_Click()
If Worksheets("sheet2").Visible = True Then
Worksheets("sheet2").Visible = False
Else
Worksheets("sheet2").Visible = True
End If
End Sub
I also want to include more than one sheet so I tried this code which
partially worked - it toggled once and then when I clicked the box again I
received a run-time error '1004':
"Unable to get the Visible property of the Sheets class".
Sub CheckBox2_Click()
If Worksheets(Array("sheet2", "sheet3")).Visible = True Then
Worksheets(Array("sheet2", "sheet3")).Visible = False
Else
Worksheets(Array("sheet2", "sheet3")).Visible = True
End If
End Sub
The code was placed in a module of the ActiveWorkBook. Where am I going
wrong? Thanks for your help.
checkbox to toggle visibility of "sheet2" listed below. It works on one and
I receive a error '9' subscript error on the machine i actually need it to
run on.
Sub CheckBox2_Click()
If Worksheets("sheet2").Visible = True Then
Worksheets("sheet2").Visible = False
Else
Worksheets("sheet2").Visible = True
End If
End Sub
I also want to include more than one sheet so I tried this code which
partially worked - it toggled once and then when I clicked the box again I
received a run-time error '1004':
"Unable to get the Visible property of the Sheets class".
Sub CheckBox2_Click()
If Worksheets(Array("sheet2", "sheet3")).Visible = True Then
Worksheets(Array("sheet2", "sheet3")).Visible = False
Else
Worksheets(Array("sheet2", "sheet3")).Visible = True
End If
End Sub
The code was placed in a module of the ActiveWorkBook. Where am I going
wrong? Thanks for your help.