Multi Level access to limit view on my multi page

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.

1612164412373.png
 

Some videos you may like

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Watch MrExcel Video

Forum statistics

Threads
1,126,957
Messages
5,621,823
Members
415,859
Latest member
Vain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top