Unhide a sheet

windsurfit

Board Regular
Joined
Mar 27, 2003
Messages
228
I have a workbook with multiple sheets. Several are hidden but the names are available in the VB.

I am looking to permanently unhide my sheet with the name "Dist"

I have been over the forum but just looking for the basics here to unhide this one sheet and maybe the other sheets in my workbook.

Thx
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Unhiding one sheet is just

Code:
Sheets("Dist").Visible = True

but what exactly do you mean by "permanently unhide" and "maybe the other sheets"?
 
Upvote 0
Since I will need it, how about complete code to unhide all hidden sheets in the workbook?

A little more complicated I'm sure. But easier then placing code into each hidden VB?
 
Upvote 0
Code:
Sub UnhideAllShts()
    Dim ws As Worksheet
 
    For Each ws In ActiveWorkbook.Worksheets
    If ws.Visible = xlSheetVeryHidden Or ws.Visible = xlSheetHidden Then _
    ws.Visible = xlSheetVisible
    Next
End Sub

or even just


Code:
Sub UnhideAllShts2()
    Dim ws As Worksheet
 
    For Each ws In ActiveWorkbook.Worksheets
        ws.Visible = xlSheetVisible
    Next ws
End Sub
 
Last edited:
Upvote 0
Ok, I tried it out.. placed the code (first you provided) in the VB for this Thisworkbook but got a error of "400" appearing.

Also tried to place it in the individual & hidden "Dist" sheet as well but with same end result. Error code 400?
 
Upvote 0
Works fine for me in a regular module (it doesn't go in a sheet module that is for worksheet event code, or in the Thisworkbook module as that that is for workbook event code. Although neither should give that error).

Are you sure you don't have any workbook protection set or you have tried adding the word Select to the code?
 
Upvote 0
Ok, confirmed I have placed into a regular module.. Now I am getting a diff error..... Runtime error 1004, Method visible of object_worksheet failed
and debug takes me to the last line in code highlighted yellow: ws.Visible = xlSheetVisible

So, getting closer?
 
Upvote 0
Can you just run the below macro to be sure please...
Code:
Sub IsWbProtected()
    With ActiveWorkbook
        If .ProtectWindows Or .ProtectStructure Then
            MsgBox "This workbook is protected"
        Else
            MsgBox "This workbook is not protected"
        End If
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,424
Members
448,961
Latest member
nzskater

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
Back
Top