G
Guest
I am trying to come up with a VB routine IN XL2007 which hides all but a
specified sheet. In the test routine I have written the specified sheet is
the first sheet, but this is arbitrary. I would be most grateful if someone
could explain the error I get when I try to compile the following:
Sub Testsub()
Dim Sheet, Sheet_ As Worksheet, I As Integer
Set Sheet = ActiveWorkbook.Sheets(1)
MsgBox ActiveWorkbook.Sheets.Count
For I = 1 To ActiveWorkbook.Sheets.Count
Set Sheet_ = ActiveWorkbook.Sheets(I)
If Sheet_ <> Sheet Then Sheet_.Hide
Next
Sheet.Activate
End Sub
specified sheet. In the test routine I have written the specified sheet is
the first sheet, but this is arbitrary. I would be most grateful if someone
could explain the error I get when I try to compile the following:
Sub Testsub()
Dim Sheet, Sheet_ As Worksheet, I As Integer
Set Sheet = ActiveWorkbook.Sheets(1)
MsgBox ActiveWorkbook.Sheets.Count
For I = 1 To ActiveWorkbook.Sheets.Count
Set Sheet_ = ActiveWorkbook.Sheets(I)
If Sheet_ <> Sheet Then Sheet_.Hide
Next
Sheet.Activate
End Sub