View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default sheet protection in excel 2003 version

John,

There was an error in it. Unhide the hidden sheet and try this version

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
MySheet = "Sheet1"' Change to suit
If ActiveSheet.Name = MySheet Then
ActiveSheet.Visible = False
response = InputBox("Enter password to view sheet")
If response = "MyPass" Then
Sheets(MySheet).Visible = True
Application.EnableEvents = False
Sheets(MySheet).Select
Application.EnableEvents = True

End If
End If
Sheets(MySheet).Visible = True
End Sub


Mike

"John" wrote:

Hi Mike
I installed your macro and when you see "sheet2" tab and clic on it,
the popup menu opens and request a password to see sheet2.
Now you type anything and the tab sheet2 disappear.
If you save the file and close it: when you reopen the file, sheet2 is
hidden and you can't reopen it because the popup menu I guess is triggered
by clicking on sheet tab2.

I deleted the macro, saved it and close the file,
When i reopen the file , sheet2 is still hidden. ( its only a test
workbook ).
It looks like a good way to hide the sheet if we can reopen it somehow.
I tried different ways ( not an expert ) but looks interesting.

Would you comment or let us know how to open sheet2
Regards
John

"Mike H" wrote in message
...
Hi,

Alt +F11 to open VB editor. Double click 'This workbook' and paste the
code
below in. This does what you want but is totally insecure. If a user
doesn't
enable macros they see your formula. Anyone with even a small amount of
knowledge and Google would view your sheet in seconds. So really my advice
is
don't do it.


Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If ActiveSheet.Name = "Sheet2" Then
ActiveSheet.Visible = False
response = InputBox("Enter password to view sheet")
If response = "MyPass" Then
Sheets("Sheet2").Visible = True
Application.EnableEvents = False
Sheets("sheet2").Select
Application.EnableEvents = True
End If
End If
End Sub


Mike

"Raviraja LIC" wrote:

Hi I am ravi raja. i have excel 2003 version. i have problem with my
excel
file. I have 2 sheets in that file. sheet no.1 and sheet no.2.

I dont want my clients to see the contents of sheet no.2 since it
contains
formulas.

i want to protect the sheet no.2 with a password. If some one click the
"sheet no.2", it should not open without a password.

Also, i came to know that this facility is available in excel 2009. I am
not
able to download the excel 2009 version.

pl help. my email id is "


Thanks

Ravi Raja