P
puiuluipui
Hi, can this be modified so an user to have acces to all sheets?
Select Case strUser
Case "Jack"
If strPword = "Secret" Then
Sheets("Jack").Visible = xlSheetVisible
Sheets("Jack").Select
Unload Me
End If
Something like allsheets.visible?
Can this be done?
This is the entire code
..............................................................................................................
UserForm1:
Option Explicit
Private Sub cmdOK_Click()
Dim strUser As String, strPword As String, strWs As String
strUser = Me.TextBox1.Value
strPword = Me.TextBox2.Value
Select Case strUser
Case "Jack"
If strPword = "Secret" Then
Sheets("Jack").Visible = xlSheetVisible
Sheets("Jack").Select
Unload Me
End If
Case "Roy"
If strPword = "Open" Then
Sheets("Roy").Visible = xlSheetVisible
Sheets("Roy").Select
Unload Me
End If
Case Else
MsgBox "Incorrect passwword or user name", vbCritical + vbOKOnly,
"Timewriting"
End Select
'optional
Sheets("main").Visible = xlSheetHidden
End Sub
Private Sub CommandButton1_Click()
Unload Me
ActiveWorkbook.Close
End Sub
Private Sub Label2_Click()
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "You can't close the form like this!You must enter your user
name & password", vbCritical + vbOKOnly, "Password required"
End If
End Su
..............................................................................................................
ThisWorkbook:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call Module1.HideAllSheets
End Sub
Private Sub Workbook_Open()
UserForm1.Show
End Su
.................................................................................................................
Module1:
Option Explicit
Sub HideAllSheets()
'make sure all sheets are hidden
Dim wSht As Worksheet
If Sheets("main").Visible = xlSheetHidden Then
Sheets("main").Visible = xlSheetVisible
End If
For Each wSht In Worksheets
If wSht.Name <> "main" And wSht.Visible = xlSheetVisible Then
wSht.Visible = xlSheetVeryHidden
End If
Next wSht
End Sub
Thanks!
Select Case strUser
Case "Jack"
If strPword = "Secret" Then
Sheets("Jack").Visible = xlSheetVisible
Sheets("Jack").Select
Unload Me
End If
Something like allsheets.visible?
Can this be done?
This is the entire code
..............................................................................................................
UserForm1:
Option Explicit
Private Sub cmdOK_Click()
Dim strUser As String, strPword As String, strWs As String
strUser = Me.TextBox1.Value
strPword = Me.TextBox2.Value
Select Case strUser
Case "Jack"
If strPword = "Secret" Then
Sheets("Jack").Visible = xlSheetVisible
Sheets("Jack").Select
Unload Me
End If
Case "Roy"
If strPword = "Open" Then
Sheets("Roy").Visible = xlSheetVisible
Sheets("Roy").Select
Unload Me
End If
Case Else
MsgBox "Incorrect passwword or user name", vbCritical + vbOKOnly,
"Timewriting"
End Select
'optional
Sheets("main").Visible = xlSheetHidden
End Sub
Private Sub CommandButton1_Click()
Unload Me
ActiveWorkbook.Close
End Sub
Private Sub Label2_Click()
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "You can't close the form like this!You must enter your user
name & password", vbCritical + vbOKOnly, "Password required"
End If
End Su
..............................................................................................................
ThisWorkbook:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call Module1.HideAllSheets
End Sub
Private Sub Workbook_Open()
UserForm1.Show
End Su
.................................................................................................................
Module1:
Option Explicit
Sub HideAllSheets()
'make sure all sheets are hidden
Dim wSht As Worksheet
If Sheets("main").Visible = xlSheetHidden Then
Sheets("main").Visible = xlSheetVisible
End If
For Each wSht In Worksheets
If wSht.Name <> "main" And wSht.Visible = xlSheetVisible Then
wSht.Visible = xlSheetVeryHidden
End If
Next wSht
End Sub
Thanks!