Can any body please help with this code I am trying to get to work.
What I am trying to do is select all the sheets in a workbook with the exception of certain named sheets..
The code is an example just to try to get it to work, the actual workbook has 76 named sheets of which there will be at least 7 sheets I do not wish to select.
Each time I run this code I get an error Object variable or With block variable not set (Error 91) I have looked in help but I am not sure what set statement I require. (if that is indeed the problem)
As always
All help is very much appreciated.
Code Below
What I am trying to do is select all the sheets in a workbook with the exception of certain named sheets..
The code is an example just to try to get it to work, the actual workbook has 76 named sheets of which there will be at least 7 sheets I do not wish to select.
Each time I run this code I get an error Object variable or With block variable not set (Error 91) I have looked in help but I am not sure what set statement I require. (if that is indeed the problem)
As always
All help is very much appreciated.
Code Below
Code:
Sub test()
Dim sh As Worksheet
Dim MyObject As Object
Set MyObject = Sheets()
If sh.Name <> Sheets("sheet3") And sh.Name <> Sheets("Sheet6") Then
Worksheets.Select
End If
End Sub