Check For SHEET if VISIBLE

HotNumbers

Well-known Member
Joined
Feb 14, 2005
Messages
732
How do i check to see if a sheet is Visible then left it visible then Unhide specific other sheets.

I have a workbook with over 50 sheets. But sometimes few are showing and the rest are veryHIdden. I want to check if a sheet is already visible then leave it visible then unhide the ones on the list that are not.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Jeffrey Smith

Well-known Member
Joined
Feb 11, 2005
Messages
795
HotNumbers,

This may help. It will only unhide worksheets that are not very hidden.

Code:
Sub UnhideWBs()

  Dim Sht As Worksheet
  
  For Each Sht In ActiveWorkbook.Worksheets
    If Sht.Visible = xlSheetHidden Then
      Sht.Visible = xlSheetVisible
    End If
  Next Sht
  
End Sub

This will only unhide selected worksheets
Code:
Sub UnhideSome()

  Dim Sht As Worksheet
  Dim Unhide As Integer
  
  
  For Each Sht In ActiveWorkbook.Worksheets
    Unhide = 0
    Select Case Sht.Name
      Case "Sheet1", "Sheet2", "Fred_Flinstone", "Barney"
        Unhide = 1
    End Select
    If Unhide = 1 Then
      If Sht.Visible = xlSheetHidden Then
        Sht.Visible = xlSheetVisible
      End If
    End If
  Next Sht


End Sub
 
Upvote 0

HotNumbers

Well-known Member
Joined
Feb 14, 2005
Messages
732
HotNumbers,

This may help. It will only unhide worksheets that are not very hidden.

Code:
Sub UnhideWBs()

  Dim Sht As Worksheet
  
  For Each Sht In ActiveWorkbook.Worksheets
    If Sht.Visible = xlSheetHidden Then
      Sht.Visible = xlSheetVisible
    End If
  Next Sht
  
End Sub

This will only unhide selected worksheets
Code:
Sub UnhideSome()

  Dim Sht As Worksheet
  Dim Unhide As Integer
  
  
  For Each Sht In ActiveWorkbook.Worksheets
    Unhide = 0
    Select Case Sht.Name
      Case "Sheet1", "Sheet2", "Fred_Flinstone", "Barney"
        Unhide = 1
    End Select
    If Unhide = 1 Then
      If Sht.Visible = xlSheetHidden Then
        Sht.Visible = xlSheetVisible
      End If
    End If
  Next Sht


End Sub

thank you... this will help
 
Upvote 0

Forum statistics

Threads
1,196,018
Messages
6,012,890
Members
441,738
Latest member
dataexcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top