Hi,
Have created a combo-box with a list of values. Depending on value in linked cell I then want to hide and unhide certain sheets.
I have tried to create an If command with Array for lists of sheets with ElseIf.
Works fine for hiding sheets, but get 'Run-time error '1004': Unable to set the Visible property of the Sheets class' when unhiding.
Please help point out where I am going wrong with this code:
Sub test()
'
' test Macro
'
If Range("A3") = 1 Then
Worksheets(Array("Test", "QLDRevenue", "QLDSummary", "QLDComments", "NSWRevenue", "NSWSummary", _
"NSWComments")).Visible = True
Worksheets("Test").Select
ElseIf Range("A3") = 2 Then
Worksheets(Array("Test", "QLDRevenue", "QLDSummary", "QLDComments")).Visible = True
Worksheets(Array("NSWRevenue", "NSWSummary", "NSWComments")).Visible = False
Worksheets("Test").Select
End If
End Sub
Thanks in advance
Have created a combo-box with a list of values. Depending on value in linked cell I then want to hide and unhide certain sheets.
I have tried to create an If command with Array for lists of sheets with ElseIf.
Works fine for hiding sheets, but get 'Run-time error '1004': Unable to set the Visible property of the Sheets class' when unhiding.
Please help point out where I am going wrong with this code:
Sub test()
'
' test Macro
'
If Range("A3") = 1 Then
Worksheets(Array("Test", "QLDRevenue", "QLDSummary", "QLDComments", "NSWRevenue", "NSWSummary", _
"NSWComments")).Visible = True
Worksheets("Test").Select
ElseIf Range("A3") = 2 Then
Worksheets(Array("Test", "QLDRevenue", "QLDSummary", "QLDComments")).Visible = True
Worksheets(Array("NSWRevenue", "NSWSummary", "NSWComments")).Visible = False
Worksheets("Test").Select
End If
End Sub
Thanks in advance