Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 355
Default Password and view of spreadsheet

Hello -

I want to create a user form that asks for a password, and according to that
password, allow the user to view only certain rows of data on certain sheets.
How would I go about doing this?

Any help will be greatly appreciated!

--
Sandy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Password and view of spreadsheet

add a sheet and in the IDE set its visible property to VERY HIDDEN ...thsi
will hold your data and being very hidded, can't be un-hid and read by the
user. you will need to protect your code to prevent your users openeing the
ide and changing the sheet's visible setting
on the hidden sheet create a table of user names in A and passwords in B
for each name add a third item in C, a comma separated list of sheets for
example that you want to be visible to this user. eg "sheet2,sheet3,sheet5"
You need to have one visible sheet, the set the visible property of all the
others to VERY HIDDEN


your userform should allow the user to enter their name and password, and is
succesful, unhide the relevent sheets.... you need to decide what to do if
they fail too of course....




Heres some code behind a userform with two text boxes and a command button.
a sheet is named passwords set as above

Option Explicit
Private counter As Long
Private Sub check_Click()
Dim sheets As Variant, index As Long
counter = counter + 1

If CheckPassword Then
sheets = Split(WorksheetFunction.VLookup(txtUserName,
Worksheets("passwords").Range("A:C"), 3, False), ",")
For index = LBound(sheets, 1) To UBound(sheets, 1)

Worksheets(sheets(index)).Visible = xlSheetVisible
Next
Unload Me
ElseIf counter = 3 Then
ThisWorkbook.Close False
Else
MsgBox "Try again"

End If

End Sub
Private Function CheckPassword() As Boolean
Dim pwd As String
With Worksheets("passwords")
On Error Resume Next
pwd = WorksheetFunction.VLookup(txtUserName, .Range("A:B"), 2, False)
On Error GoTo 0
If pwd = "" Then Exit Function
CheckPassword = (pwd = txtPassword)
End With
End Function






"Sandy" wrote:

Hello -

I want to create a user form that asks for a password, and according to that
password, allow the user to view only certain rows of data on certain sheets.
How would I go about doing this?

Any help will be greatly appreciated!

--
Sandy

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 355
Default Password and view of spreadsheet

Thank you very much, Patrick!
--
Sandy


"Patrick Molloy" wrote:

add a sheet and in the IDE set its visible property to VERY HIDDEN ...thsi
will hold your data and being very hidded, can't be un-hid and read by the
user. you will need to protect your code to prevent your users openeing the
ide and changing the sheet's visible setting
on the hidden sheet create a table of user names in A and passwords in B
for each name add a third item in C, a comma separated list of sheets for
example that you want to be visible to this user. eg "sheet2,sheet3,sheet5"
You need to have one visible sheet, the set the visible property of all the
others to VERY HIDDEN


your userform should allow the user to enter their name and password, and is
succesful, unhide the relevent sheets.... you need to decide what to do if
they fail too of course....




Heres some code behind a userform with two text boxes and a command button.
a sheet is named passwords set as above

Option Explicit
Private counter As Long
Private Sub check_Click()
Dim sheets As Variant, index As Long
counter = counter + 1

If CheckPassword Then
sheets = Split(WorksheetFunction.VLookup(txtUserName,
Worksheets("passwords").Range("A:C"), 3, False), ",")
For index = LBound(sheets, 1) To UBound(sheets, 1)

Worksheets(sheets(index)).Visible = xlSheetVisible
Next
Unload Me
ElseIf counter = 3 Then
ThisWorkbook.Close False
Else
MsgBox "Try again"

End If

End Sub
Private Function CheckPassword() As Boolean
Dim pwd As String
With Worksheets("passwords")
On Error Resume Next
pwd = WorksheetFunction.VLookup(txtUserName, .Range("A:B"), 2, False)
On Error GoTo 0
If pwd = "" Then Exit Function
CheckPassword = (pwd = txtPassword)
End With
End Function






"Sandy" wrote:

Hello -

I want to create a user form that asks for a password, and according to that
password, allow the user to view only certain rows of data on certain sheets.
How would I go about doing this?

Any help will be greatly appreciated!

--
Sandy

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
unprotect password in VBA view exalan Excel Worksheet Functions 1 March 4th 10 01:05 PM
Password protection in macro ( Anybody can view my password in VB Sherees Excel Discussion (Misc queries) 2 January 24th 10 10:05 PM
Tab password to view jackrobyn1 Excel Discussion (Misc queries) 1 September 13th 08 09:12 AM
Password protect for view only Kathy Excel Discussion (Misc queries) 2 April 5th 06 05:04 PM
Password to view VB code for Village software.xlt cindy Excel Programming 2 August 13th 03 12:17 PM


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

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

About Us

"It's about Microsoft Excel"