Jeorge
New Member
- Joined
- Nov 27, 2015
- Messages
- 32
Hi Guys,
I have a userform1 log in with admin and regular users, I wanted to limit the access of regular users to 2 pages only and hide the other two (As I am having 4 pages multi-page userform3) and the 4 pages can be viewed by the Admin users. I have this code for my Userform Log-In:
Private Sub CB1_Click()
Dim AddData As Range, Current As Range
Dim user As Variant, Code As Variant
Dim PName As Variant, AName As Variant
Dim ws As Worksheet, ws2 As Worksheet, ws3 As Worksheet, ws4 As Worksheet, ws5 As Worksheet
Dim result As Integer
Dim TitleStr As String
Dim msg As VbMsgBoxResult
user = Me.TB1.Value
Code = Me.TB2.Value
TitleStr = "Password check"
result = 0
Set Current = Sheet5.Range("P3")
On Error GoTo errHandler:
Set AddData = Sheet5.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0)
If user <> "" And Not IsNumeric(user) And Code <> "" And IsNumeric(Code) Then
For Each AName In Sheet5.Range("U3:U10")
If AName = CLng(Code) And AName.Offset(0, -1) = user Then ' Use this for passcode numbers only
MsgBox "Welcome: – " & user & " "
AddData.Value = user
AddData.Offset(0, 1).Value = Now
Current.Value = user
result = 1
UserForm2.Show
LogIn.Hide
Exit Sub
End If
Next AName
End If
If user <> "" And Not IsNumeric(user) And Code <> "" And IsNumeric(Code) Then
For Each PName In Sheet5.Range("F3:F100")
If PName = CLng(Code) And PName.Offset(0, -1) = user Then ' Use this for passcode numbers only
MsgBox "Welcome: – " & user & " "
AddData.Value = user
AddData.Offset(0, 1).Value = Now
Current.Value = user
UserForm2.Show
LogIn.Hide
After clicking the CB1 then it will open the Userform3 with the multi page (as image below). Thank you for all the help that you can extend guys.
I have a userform1 log in with admin and regular users, I wanted to limit the access of regular users to 2 pages only and hide the other two (As I am having 4 pages multi-page userform3) and the 4 pages can be viewed by the Admin users. I have this code for my Userform Log-In:
Private Sub CB1_Click()
Dim AddData As Range, Current As Range
Dim user As Variant, Code As Variant
Dim PName As Variant, AName As Variant
Dim ws As Worksheet, ws2 As Worksheet, ws3 As Worksheet, ws4 As Worksheet, ws5 As Worksheet
Dim result As Integer
Dim TitleStr As String
Dim msg As VbMsgBoxResult
user = Me.TB1.Value
Code = Me.TB2.Value
TitleStr = "Password check"
result = 0
Set Current = Sheet5.Range("P3")
On Error GoTo errHandler:
Set AddData = Sheet5.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0)
If user <> "" And Not IsNumeric(user) And Code <> "" And IsNumeric(Code) Then
For Each AName In Sheet5.Range("U3:U10")
If AName = CLng(Code) And AName.Offset(0, -1) = user Then ' Use this for passcode numbers only
MsgBox "Welcome: – " & user & " "
AddData.Value = user
AddData.Offset(0, 1).Value = Now
Current.Value = user
result = 1
UserForm2.Show
LogIn.Hide
Exit Sub
End If
Next AName
End If
If user <> "" And Not IsNumeric(user) And Code <> "" And IsNumeric(Code) Then
For Each PName In Sheet5.Range("F3:F100")
If PName = CLng(Code) And PName.Offset(0, -1) = user Then ' Use this for passcode numbers only
MsgBox "Welcome: – " & user & " "
AddData.Value = user
AddData.Offset(0, 1).Value = Now
Current.Value = user
UserForm2.Show
LogIn.Hide
After clicking the CB1 then it will open the Userform3 with the multi page (as image below). Thank you for all the help that you can extend guys.