Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default tab password

How can I create different passwords for 1 worksheet with differnt tabs to
prevent individuals from seeing other tabs?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default tab password

Hi Keni2020,

Try something like:

'=============
Option Explicit

Private Const sStr As String = "COMMON" '<<=== CHANGE

'-------------

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim SH As Object

For Each SH In Me.Sheets
With SH
If UCase(.Name) < sStr Then
SH.Visible = xlSheetVeryHidden
End If
End With
Next SH
End Sub

'-------------

Private Sub Workbook_Open()
Dim SH As Object
Dim arr As Variant
Dim res As String

res = InputBox("Please enter password")

Select Case res
Case "MICKEY": arr = Array("Sheet1", "Sheet3") '<<=== CHANGE
Case "MINNIE": arr = Array("Sheet1", "Sheet2") '<<=== CHANGE
Case "MOUSE": arr = Array("Sheet2") '<<=== CHANGE
Case Else: Exit Sub
End Select

For Each SH In Me.Sheets
With SH
If IsError(Application.Match(.Name, arr, 0)) Then
If UCase(.Name) < sStr Then
SH.Visible = xlSheetVeryHidden
End If
Else
.Visible = xlSheetVisible
End If
End With
Next SH

End Sub
'<<=============

Change "COMMON" to the name of a sheet (perhaps an empty dummy sheet) which
should be available to all users - at least one sheet must be visible in any
workbook.

Change MICKEY, MINNIE and MOUSE to your required passwords.

Change the sheet arrays to reflect the sheets which should be available to
the respective user.

This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not* a standard module or a sheet module:

Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is maximised)
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman


"keni2020" wrote in message
...
How can I create different passwords for 1 worksheet with differnt tabs to
prevent individuals from seeing other tabs?



Reply
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
How to retrive password protected worksheet but forgot password? Laurie Excel Worksheet Functions 1 November 19th 09 09:42 PM
PASSWORD REMOVAL I have the password to open the file and the password to modify the file now how to remove them LJ[_4_] Excel Programming 0 April 27th 06 03:18 AM
how to automate opening a password protected excel file? e.g. a .xls that has a password set in the security tab. Daniel Excel Worksheet Functions 0 June 23rd 05 11:56 PM
bypass password when update linking of password protected file Yan Excel Discussion (Misc queries) 1 February 7th 05 11:29 PM
Excel password but cant hide the sheets before entering password cakonopka[_3_] Excel Programming 1 January 30th 04 06:28 PM


All times are GMT +1. The time now is 09:55 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"