0
votes

I have an Excel workbook that has three tabs. Two of which are hidden. When I try an unhide the hidden worksheets worksheets the unhide option is greyed out. I have opened the project window in VBA IDE and can see that the Visible options are set to 0- xlSheetHidden for the two sheets. I have tried to change the visibility here to -1 -xlSheetVisable but I get the error:

Unable to set the Visibility property of the Worksheet Class.

I have also tied to unhide the sheets with the following code:

Sub UnhideAllSheets()    
    'Unhide all sheets in workbook.    
    Dim ws As Worksheet

    For Each ws In ActiveWorkbook.Worksheets 
        ws.Visible = xlSheetVisible
    Next ws
End Sub

But I get the error:

Run-time 'Visible of object'_Worksheet' failed

The worksheets do exist and there are no passwords or any protection anywhere in the workbook.

1
Is the workbook or any worksheet protected?Ricardo Diaz
workbook not protected, the sheet I can see is not protected, unsure for the two sheets I can't seeStacey
Have a looke here to see what OP there did to resolve the issueJvdV
try For Each ws In ThisWorkbook.Sheets If ws.Visible = xlSheetHidden Then ws.Unprotect to check if the hidden sheets are protectedJLCH
Are you 100% sure that the workbook is not protected? Press Alt - T - P - W to checkSiddharth Rout

1 Answers

0
votes

I don't know why but I've never had any success using ws.Visible = xlSheetVisible. I always use:

ws.Visible = True

and it always works!