Here is my code. I tried your example and still got the same error.
Private Sub cmdSubmit_Click()
Dim HidWks As Worksheet
Dim res As Variant
Set HidWks = Worksheets("Sheet3")
With HidWks
res = Application.Match(Me.txtUswNumber.Value, .Range("a:a"), 0)
If IsError(res) Then
MsgBox "Invalid User Id"
Exit Sub
Else
If CStr(.Range("a:a")(res, 2).Value) < Me.txtPassword.Value Then
MsgBox "Invalid password for ID"
Exit Sub
End If
End If
With .Parent.Worksheets(.Range("a:a")(res, 3).Value)
.Visible = xlSheetVisible
.Select
.Range("a1").Select
End With
Unload Me
End With
Unload Me
End Sub
Worksheet 3 has:
616 caleb616 Sheet4
520 Alex520 Sheet5
628 Brandi628 Sheet6
Thanks Again.
"Dave Peterson" wrote:
Do you have extra spaces in column A (or in the textbox)?
If you take the value in the textbox and paste it into D1 (say) of the Hidden
worksheet, what does:
=match(d1,a:a,0)
show?
cwwolfdog wrote:
Thanks for your help,
i am having a problem I believe with the .range ("a:a"), 0) Everytime I run
the form it comes back with invalid user id. I am probably missing something
very basic.
Thanks Again.
"Dave Peterson" wrote:
First, worksheet protection is pretty easy to break. In just moments, everyone
can see your list of id's/passwords.
And the protection for the VBA project is easy to break so that users can see
your code, too.
If that data is really private/confidential, don't share it in excel.
But this may get you closer if you still want to use it.
I put my id's in column A, the passwords in column B and the worksheets to go to
in column C of the worksheet named Hidden:
Option Explicit
Private Sub CommandButton1_Click()
Dim HidWks As Worksheet
Dim res As Variant
Set HidWks = Worksheets("hidden")
With HidWks
res = Application.Match(Me.TextBox1.Value, .Range("a:a"), 0)
If IsError(res) Then
MsgBox "Invalid User Id"
Exit Sub
Else
If CStr(.Range("a:a")(res, 2).Value) < Me.TextBox2.Value Then
MsgBox "Invalid password for ID"
Exit Sub
End If
End If
With .Parent.Worksheets(.Range("a:a")(res, 3).Value)
.Visible = xlSheetVisible
.Select
.Range("a1").Select
End With
Unload Me
End With
End Sub
cwwolfdog wrote:
I am using a userform to get employees id number and passwords. I have the
id numbers and passwords on a hidden sheet. I need to code in the submit
button on the form a way to search the hidden sheet for there id number and
password match and then if it does match take them to a specific sheet.
Should I be going about this in a different manner or is this possible?
Thanks
--
Dave Peterson
--
Dave Peterson
|