ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   password protect a sheet (https://www.excelbanter.com/excel-discussion-misc-queries/207930-password-protect-sheet.html)

Joe

password protect a sheet
 
Is there a way to prevent someone from viewing a worksheet. I know that I
can hide the worksheet and then password protect the workbook to prevent the
user from unhiding the sheet. I would prefer to still see the tabs but not
allow anyone to view that worksheet.


Mike H

password protect a sheet
 
Joe,

Alt+F11 to open VB editor, double click 'This Workbook' and paste the code
below in on the right. Change the name of the worksheet to the one you want
to protect.

You should be aware that there is no foolproof way of doing this and that
this method is a deterrent only.


Private Sub Workbook_SheetActivate(ByVal Sh As Object)
ws = ("Sheet2")
If ActiveSheet.Name = (ws) Then
ActiveSheet.Visible = False
response = InputBox("Enter password")
If response = "MyPass" Then
Sheets(ws).Visible = True
Application.EnableEvents = False
Sheets(ws).Activate
Application.EnableEvents = True
Else
MsgBox "Your not allowed to see that sheet"
Sheets(ws).Visible = True
End If
End If
End Sub


Mike


"Joe" wrote:

Is there a way to prevent someone from viewing a worksheet. I know that I
can hide the worksheet and then password protect the workbook to prevent the
user from unhiding the sheet. I would prefer to still see the tabs but not
allow anyone to view that worksheet.


ShaneDevenshire

password protect a sheet
 
Hi,

You can choose Format, Cells, Protection and turn on Hidden. Then you can
select the range you don't want the user to view and change its Number format
to the custom format ;;; and then reprotect the spreadsheet.

--
Thanks,
Shane Devenshire


"Joe" wrote:

Is there a way to prevent someone from viewing a worksheet. I know that I
can hide the worksheet and then password protect the workbook to prevent the
user from unhiding the sheet. I would prefer to still see the tabs but not
allow anyone to view that worksheet.


Gord Dibben

password protect a sheet
 
Not sure why you want to see a sheet tab but not the contents but......

You could format all cells to locked and hidden under
FormatCellsProtection.

Then Format all cells to white text.

Protect the sheet and not allow users to select locked or unlocked cells or
anything else.

Note: Excel internal security is very weak and passwords easily cracked.


Gord Dibben MS Excel MVP

On Mon, 27 Oct 2008 12:03:13 -0700, Joe
wrote:

Is there a way to prevent someone from viewing a worksheet. I know that I
can hide the worksheet and then password protect the workbook to prevent the
user from unhiding the sheet. I would prefer to still see the tabs but not
allow anyone to view that worksheet.



Joe

password protect a sheet
 
Thanks, I'll try this.

"Mike H" wrote:

Joe,

Alt+F11 to open VB editor, double click 'This Workbook' and paste the code
below in on the right. Change the name of the worksheet to the one you want
to protect.

You should be aware that there is no foolproof way of doing this and that
this method is a deterrent only.


Private Sub Workbook_SheetActivate(ByVal Sh As Object)
ws = ("Sheet2")
If ActiveSheet.Name = (ws) Then
ActiveSheet.Visible = False
response = InputBox("Enter password")
If response = "MyPass" Then
Sheets(ws).Visible = True
Application.EnableEvents = False
Sheets(ws).Activate
Application.EnableEvents = True
Else
MsgBox "Your not allowed to see that sheet"
Sheets(ws).Visible = True
End If
End If
End Sub


Mike


"Joe" wrote:

Is there a way to prevent someone from viewing a worksheet. I know that I
can hide the worksheet and then password protect the workbook to prevent the
user from unhiding the sheet. I would prefer to still see the tabs but not
allow anyone to view that worksheet.


Gord Dibben

password protect a sheet
 
And how will that allow you to see the sheet tab but not the contents as
your original post required?


Gord

On Mon, 27 Oct 2008 13:20:07 -0700, Joe
wrote:

Thanks, I'll try this.

"Mike H" wrote:

Joe,

Alt+F11 to open VB editor, double click 'This Workbook' and paste the code
below in on the right. Change the name of the worksheet to the one you want
to protect.

You should be aware that there is no foolproof way of doing this and that
this method is a deterrent only.


Private Sub Workbook_SheetActivate(ByVal Sh As Object)
ws = ("Sheet2")
If ActiveSheet.Name = (ws) Then
ActiveSheet.Visible = False
response = InputBox("Enter password")
If response = "MyPass" Then
Sheets(ws).Visible = True
Application.EnableEvents = False
Sheets(ws).Activate
Application.EnableEvents = True
Else
MsgBox "Your not allowed to see that sheet"
Sheets(ws).Visible = True
End If
End If
End Sub


Mike


"Joe" wrote:

Is there a way to prevent someone from viewing a worksheet. I know that I
can hide the worksheet and then password protect the workbook to prevent the
user from unhiding the sheet. I would prefer to still see the tabs but not
allow anyone to view that worksheet.




All times are GMT +1. The time now is 12:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com