Macros 2

  • Thread starter Thread starter Sri Harsha
  • Start date Start date
S

Sri Harsha

I want to record a macro which hides all the open sheets other than sheet 1.
Can some one tell me how to do that?
 
Sub HideAll()
Dim wsX As Worksheet
With Worksheets
For Each wsX In Worksheets
If wsX.Name <> "Sheet1" Then wsX.Visible = xlSheetHidden
Next
End With
End Sub
 
With Activeworkbook

.Worksheets("Sheet1").Visible = xlSheetVisible
For Each sh In .Worksheets

If sh.Name <> "Sheet1" Then

sh.Visible = xlSheetHidden
End If
Next sh
End With
 
Hi Harsha

Please try the below code.

If this helps click Yes
---------------
Jacob Skaria

Dim intSheets
For intSheets = 1 To ActiveWorkbook.Sheets.Count
If intSheets > 1 Then
ActiveWorkbook.Sheets(intSheets).Visible = False
End If
Next
 
Try something like

Sub AAA()
Dim N As Long
With ThisWorkbook.Worksheets
For N = 2 To .Count
.Item(N).Visible = False
Next N
End With
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top