hey!
I have a multi user workbook i would like to ask for some help. I have crated a login sheet where i can write user id and password for this workbook.
I have then crated a loop to make it look for the user if it match you get access. This is where i am stuck i cant get it to give different users different rights to see sheets.
For example want user1 to only see and use sheet 1 and user 2 to only see and use sheet 2. I am very grateful for any help
ps. My excel is in swedish so blad=Sheet
Here is my Code:
Private Sub CommandButton1_Click()
Dim Uname As String, Upwd As Variant 'sätter uname som text och Upwd som variant
Uname = UserForm1.TextBox1.Value 'användarnamn = Uname
Upwd = UserForm1.TextBox2.Value 'Lösenord = Upwd
If Uname <> "" And Upwd <> "" Then 'om det står ett värde i användarnamn och lösenord då ska
Blad6.Range("D2").Value = Uname ' Användernamnet kopieras till Login bladet
Blad6.Range("D3").Value = Upwd 'Lösenordet kopierat till Login bladet
Else
MsgBox "Användernamn och Lösenord Saknas!" 'om man inte skriver ett Anamn eller Lösen Då visas det här meddelandet
Exit Sub
End If
Dim rng As Range
Dim UnameRange As Range: Set UnameRange = Range("A2", "A10")
For Each rng In UnameRange
If Blad6.Range("D2").Value = rng.Value Then
rng.Offset(0, 1).Select
Range("F3").Value = Selection.Value
Range("F2").Value = rng.Value
End If
Next
If Range("D2").Value = Range("F2").Value And Range("D3").Value = Range("F3").Value Then
MsgBox "Du är nu inloggad"
Else
MsgBox "Ange rätt användar namn och lösenord!"
Range("F3").Value = ""
Range("F2").Value = ""
End If
TextBox1.Value = ""
TextBox2.Value = ""
End Sub
I have a multi user workbook i would like to ask for some help. I have crated a login sheet where i can write user id and password for this workbook.
I have then crated a loop to make it look for the user if it match you get access. This is where i am stuck i cant get it to give different users different rights to see sheets.
For example want user1 to only see and use sheet 1 and user 2 to only see and use sheet 2. I am very grateful for any help
ps. My excel is in swedish so blad=Sheet
Here is my Code:
Private Sub CommandButton1_Click()
Dim Uname As String, Upwd As Variant 'sätter uname som text och Upwd som variant
Uname = UserForm1.TextBox1.Value 'användarnamn = Uname
Upwd = UserForm1.TextBox2.Value 'Lösenord = Upwd
If Uname <> "" And Upwd <> "" Then 'om det står ett värde i användarnamn och lösenord då ska
Blad6.Range("D2").Value = Uname ' Användernamnet kopieras till Login bladet
Blad6.Range("D3").Value = Upwd 'Lösenordet kopierat till Login bladet
Else
MsgBox "Användernamn och Lösenord Saknas!" 'om man inte skriver ett Anamn eller Lösen Då visas det här meddelandet
Exit Sub
End If
Dim rng As Range
Dim UnameRange As Range: Set UnameRange = Range("A2", "A10")
For Each rng In UnameRange
If Blad6.Range("D2").Value = rng.Value Then
rng.Offset(0, 1).Select
Range("F3").Value = Selection.Value
Range("F2").Value = rng.Value
End If
Next
If Range("D2").Value = Range("F2").Value And Range("D3").Value = Range("F3").Value Then
MsgBox "Du är nu inloggad"
Else
MsgBox "Ange rätt användar namn och lösenord!"
Range("F3").Value = ""
Range("F2").Value = ""
End If
TextBox1.Value = ""
TextBox2.Value = ""
End Sub