LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Junior Member
 
Posts: 22
Send a message via Skype™ to Bakar
Default

Quote:
Originally Posted by Ben McClave View Post
Bakar,

This might work, although you'll want to password protect the code for the userform before circulating your final workbook. The idea of this series of macros is that all but one sheet are "veryhidden" when the file closes. The one visible sheet will have a message that alerts users to ensure macros are enabled, and may also include a button for unlocking the workbook (the code of which would simply be Userform1.Show).

Once you have this first sheet set up, go to the "ThisWorkbook" module and paste the following:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.CodeName = "Sheet1" Then
ws.Visible = True
Else
ws.Visible = xlSheetVeryHidden
End If
Next ws
End Sub

Private Sub Workbook_Open()
UserForm1.Show
End Sub

Then, create a Userform with two textboxes (username and password) and two buttons (OK and Cancel). On the password textbox, set the PasswordChar Property to "*" or another masking character if you wish. Then, in the Userform module, paste this code:

Private Sub CommandButton1_Click()
Dim i As Long
Dim ws As Worksheet
Dim sPWord(1 To 5) As String
Dim sUser(1 To 5) As String

sUser(1) = "Test"
sPWord(1) = "Testme"
'fill in others as well...

Select Case TextBox1
Case sUser(1)
i = 1
Case sUser(2)
i = 2
Case sUser(3)
i = 3
Case sUser(4)
i = 4
Case sUser(5)
i = 5
Case Else
MsgBox "Invalid User ID or Password"
Exit Sub
End Select

If TextBox2 = sPWord(i) Then
For Each ws In Worksheets
If ws.CodeName = "Sheet1" Then
'Do nothing
Else
ws.Visible = True
End If
Next ws
Sheet1.Visible = xlSheetVeryHidden
Unload Me
Else
MsgBox "Invalid User ID or Password"

End If

End Sub

Private Sub CommandButton2_Click()
Unload Me
End Sub



The first few variables will be the usernames and passwords. If the textbox info matches a username and its corresponding password, all sheets will be made visible except for Sheet1, which will become "VeryHidden". If the entries do not match, the users will receive an error message.

You can customize this code from here, but I think this will get you started.

Ben
Thanks this is fantastic
BUT I need to give access to one user only sheet 2 and now all sheets are opened
I must give to different user different sheet to work

Example user 1 sheet3 only remaining sheet is hidden etc

Thnxs again

Bakar
 
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
collecting fata from all sheets into one sheet lana.b Excel Worksheet Functions 4 January 26th 09 08:08 PM
Collecting data from excel forms into one spread sheet phi Excel Programming 0 June 26th 07 04:33 AM
collecting data from many sheets to one sheet Khoshravan Excel Discussion (Misc queries) 12 June 7th 07 10:01 PM
collecting data from one sheet to another d_kight Excel Discussion (Misc queries) 0 October 12th 06 07:06 PM
Collecting the names from other sheet for print Irshad Alam Excel Discussion (Misc queries) 0 March 6th 06 07:49 AM


All times are GMT +1. The time now is 08:25 PM.

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"