Thread: Hide sheets
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Kevin B Kevin B is offline
external usenet poster
 
Posts: 1,316
Default Hide sheets

I named the range of cells containing the worksheet names "MyList" and used
the following code:

Sub HideAway()

Dim w As Worksheet
Dim r As Range
Dim i As Integer
Dim strSheet As String

Set r = Range("MyList")

For i = 1 To r.Cells.Count
strSheet = r.Cells(i)
For Each w In ThisWorkbook.Worksheets
If w.Name = strSheet Then
w.Visible = xlSheetHidden
End If
Next w
Next i

Set w = Nothing
Set r = Nothing

End Sub
--
Kevin Backmann


"Steve" wrote:

Hi all. I have a list of sheets within the workbook in the range
Sheet1 A1:A10. How can I have vba hide the sheets that are listed in
that range? Thanks!