LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Protect each worksheet individually

On 9 Nov., 17:34, Gord Dibben wrote:
Please note off the top that Excel's internal security is very weak.

It is designed to lock out casual users and prevent accidental overwrites and
viewing.

Are you and your users on a network?

Could you make do with code that makes use of the login username to make visible
just that user's sheet when the workbook is opened?

Requires a blank "Dummy" sheet because you cannot hide all sheets in a workbook.

Sheetnames will be "username1heet", "username2sheet"

Paste this code into Thisworkbook Module.

Private Sub Workbook_Open()
Dim pword As String
On Error GoTo endit
Select Case Environ("Username")

* * * Case Is = Environ("Username"): Sheets((Environ("Username") _
* * * & "Sheet")).Visible = True

End Select
Sheets("Dummy").Visible = False
Exit Sub
endit:
MsgBox "Incorrect Password"
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim sht As Worksheet
Application.ScreenUpdating = False
* * * *Sheets("Dummy").Visible = xlSheetVisible
* * * * * *For Each sht In ActiveWorkbook.Sheets
* * * * * *If sht.Name < "Dummy" Then
* * * sht.Visible = xlSheetVeryHidden
End If
Next sht
Application.ScreenUpdating = True
ThisWorkbook.Save
End Sub

'To allow you as Administrator to see all sheets.
'
'In a general module...............

Sub UnHideAllSheets()
* * Application.ScreenUpdating = False
* * Dim n As Single
* * For n = 1 To Sheets.Count
* * * * Sheets(n).Visible = True
* * Next n
* * Application.ScreenUpdating = True
End Sub

Be sure to lock the project from viewing so's users cannot access the code.

If not on a network, the code can be revised to employ actual password inputs as
you asked.

Gord Dibben * * MS Excel MVP

On Tue, 9 Nov 2010 03:15:19 -0800 (PST), andreashermle
wrote:

Dear Experts:


I wonder whether the following is feasible:


I got a multi-sheet (6 Worksheets) workbook where the following
actions are to be performed via VBA


a) perform the action 'very hidden' on all the 6 worksheets, ie., no
worksheets are visible when file is opened.
b) An individual 'Open' password is to be assigned to all worksheets.
Each worksheet has got its own 'Open' Password
b) If workbook is opened an input box prompts the user to enter his
password which opens only his worksheet. The other ones are still
'very hidden'
c) After closing the file/workbook, the just worked on worksheet gets
'very hidden' again.


Is this feasible.


Thank you very much in advance for your great/professional help.


Regards, Andreas


HI Gord,

works like a charm. Thank you very much for your great and
professional help.

Regards, Andreas


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can protect worksheet then workbook but not Protect and Share in code [email protected] Excel Programming 7 January 16th 17 07:01 AM
how can i see all column sizes at once not individually? Mary Lou Excel Discussion (Misc queries) 1 November 14th 07 07:55 PM
Importing XML records individually Zarch Excel Programming 2 June 5th 07 05:48 PM
How do I set up a date to update individually on each worksheet? chefbeavrdee Excel Programming 1 August 28th 06 04:43 PM
Sorting each row individually yaghani Excel Programming 3 June 11th 04 03:28 AM


All times are GMT +1. The time now is 03:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"