Protect and Hide a Worksheet tab?

FinancialAnalystKid

Well-known Member
Joined
Oct 14, 2004
Messages
779
Is there a way to protect and hide a worksheet so other people cannot unhide and view it or know there is a tab hidden?

There is confidential information I need to hide without breaking up workbook into different copies.

Thanks!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Try like this

Code:
Sub HideSheet()
With Sheets("Sheet1")
    .Protect Password:="pw"
    .Visible = xlSheetVeryHidden
End With
End Sub
 
Upvote 0
Try like this

Code:
Sub HideSheet()
With Sheets("Sheet1")
    .Protect Password:="pw"
    .Visible = xlSheetVeryHidden
End With
End Sub


Hmm...

Which leads me to: Is there a way to set a password so if someone wants to unhide a tab they are asked for a password. They need permission to view it?

I worry that if someone knows VBA and knows there is a hidden sheet they will be able to use the above script to unhide worksheets!
 
Last edited:
Upvote 0
Not telling :stickouttounge:































Code:
Sub UnHideSheet()
With Sheets("Sheet1")
    .Unprotect Password:="pw"
    .Visible = xlSheetVisible
End With
End Sub
 
Upvote 0
Make sure you set the PW for the VB editor to "lock for viewing" as well, otherwise any user can open up VB, select your sheet, and change the visible setting to 'Visible'.

You realize that no password in Excel is truly secure? I would never put any truly confidential data in a public workbook.
 
Upvote 0
Not telling :stickouttounge:

LOL I figured it out but...

Which leads me to: Is there a way to set a password so if someone wants to unhide a tab they are asked for a password. They need permission to view it?

I worry that if someone knows VBA and knows there is a hidden sheet they will be able to use the above script to unhide worksheets!
 
Upvote 0
Make sure you set the PW for the VB editor to "lock for viewing" as well, otherwise any user can open up VB, select your sheet, and change the visible setting to 'Visible'.

You realize that no password in Excel is truly secure? I would never put any truly confidential data in a public workbook.

The script will be on my Personal computer right? I'm not saving it in the sheet it will only be with 'me' so-to-speak if I only save it in my personal.xlsb right?

Now, how do you lock for viewing anyway?
 
Upvote 0
Open VB Editor, go to menu Tools/VBA Project Properties

Then select tab "Protection"

Check box and type a password. Save file, then close and reopen your spreadsheet, open the VB Editor again and note the difference.

Regardless of whether the macro code is in the workbook or your personal workbook, it all depends on where the physical data resides. If it is in your regular workbook then be careful about sending it out. Do some google searches on excel security and you will quickly see that you don't want to put your life in its hands.
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,704
Members
452,938
Latest member
babeneker

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