PDA

View Full Version : validating values in excel using VBA



maddiashok
05-12-2010, 11:04 PM
Hi,
I created login form with user name and password as text boxes and one submit button.
then what am i trying is once i click on submit button. it should check entered user and and password is right or not.
already i created one sheet user_info it contains users and passwords.

Then the problem is am not able to validate user and password existed or not.

i am new to VBA.
Please help me for my query.

Thanks in Advance.

Bob Phillips
05-13-2010, 12:45 AM
On Error Resume Next
UserRow = Application.Match(txtUsername.Text, Worksheets("user_info").Range("A:A"),0)
PasswordRow = Application.Match(txtPassword.Text, Worksheets("user_info").Range("B:B"),0)
On Error Goto 0

If UserRow > 0 Then MsgBox "User found"
If PasswordRow > 0 Then MsgBox "Password found"

maddiashok
05-13-2010, 03:14 AM
Hi,
Sorry to say this. It will work but not fare to my problem.

It will check user and password separately. there will be chance to match one user with other user password.

But i have to check particular user corresponding password only not entire column.

Thanku for reply!

Bob Phillips
05-13-2010, 05:22 AM
Just check that UserRow and PasswordRow have the same value. It ain't rocket science!