Specific user sheet

  • Thread starter Thread starter spinner
  • Start date Start date
S

spinner

does anyone know how to program in VB (Excel) so that users only can open a
excel sheet with there name?
Let me know
 
Hi
in addition to Ron (as I'm also not so sure what you want to protect).
But for worksheets you can apply individual password per page ('Tools -
Protection'). Or maybe a more comfortable way (just as an idea):
- create a start page in your workbook with buttons for each person (or
ask the user at startup for his name and store this name somethere in
your code/workbook)
- After clicking on this button HIS personal worksheet will be unhidden
(after entering a password - of course)

Note: Excel is not that secure, so a determined user can overcome this
security features
 
I think you're looking for something along the following lines, just change
sheet names, passwords etc:-

With this in the ThisWorkbook Module

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim wks As Worksheet
ActiveWorkbook.Unprotect ("abcd")

For Each wks In ActiveWorkbook.Worksheets
If wks.Name <> "Intro" Then
wks.Visible = xlVeryHidden
End If
Next wks

With ActiveWorkbook
.Protect Password:="abcd123efg"
.Save
End With

End Sub

-----------------------------------------------------------


and with the following in a normal module

Sub NoPeekingNow()

Dim Ans As String

ActiveWorkbook.Unprotect ("abcd123efg")
Ans = InputBox("Please input your password")

If Ans = "cdef" Then
Sheets("Sheet1").Visible = True
Sheets("Sheet2").Visible = True
Else
If Ans = "ghij" Then
Sheets("Sheet3").Visible = True
Sheets("Sheet4").Visible = True
Else
If Ans = "hijk" Then
Sheets("Sheet5").Visible = True
Sheets("Sheet6").Visible = True
Else
If Ans = "ijkl" Then
Sheets("Sheet7").Visible = True
Sheets("Sheet8").Visible = True
Else
If Ans = "klmn" Then
Sheets("Sheet9").Visible = True
Sheets("Sheet10").Visible = True
Else
If Ans = "lmnp" Then
Sheets("Sheet11").Visible = True
Sheets("Sheet12").Visible = True

Else: MsgBox "Try Again, or Stop if you're not supposed to be
trying"
End If
End If
End If
End If
End If
End If

ActiveWorkbook.Protect Password:="abcd"

End Sub


The workbook will open with only the Intro sheet showing, even if they disable
macros. Have a button on the intro sheet that says get My data or something and
link it to the NoPeekingNow sub. Whne they hit the button they will be
prompted for their password, and on receipt of the correct password will get
just their data. Make sure you protect the code as well though, else they will
see it. Nothing's totally secure though, so be careful what you put in. Will
withstand most users casual access attempts though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top