Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
3 conditions if else statement.
Hi Guys,
I'm currently having troubles to fufill the 3 conditions in the if els statement which I have coded. This if-else statement is used in the password checking system wher the usernames and passwords are all stored in a spreadsheet. Beside usernames and passwords, there are 2 groups where users belong to. The are 'A' - Administrators, and 'N' - Normal Users. In the if-else statement, I plan to code it in such a way that it wil scan through the spreadsheet looking for the username and once i matches, it will offset by (0, 1) to compare the password. After which the code should offset again to check for the usergroup so as to show different menu between administrators and users. The following code which I coded, unfortunately does not work due t some reasons. :( Will be really grateful if someone coul assist. Lastly, sorry for the wrong post. Regards, Kenneth --- Sub OkBtn_Click() Dim a As Integer Dim Name As String Dim Pass As String Dim Group As String Name = UserNameTB.Value Pass = PasswordTB.Value Cells(1, 1).Select For a = 1 To 20 If Name = ActiveCell.Value And Pass = ActiveCell.Offset(0 1).Value Then GoTo GroupCompare MsgBox ("Wrong Password!") Next a Cells(1, 1).Select GroupCompa If ActiveCell.Offset(0, 2) = "N" Then Show TimesheetEntry ElseIf ActiveCell.Offset(0, 2) = "A" Then Show LoginOption End If End Sub -- -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
3 conditions if else statement.
Kenneth,
Private Sub OkBtn_Click() Dim strUsername As String, strPassword As String Dim i As Long, lngLastRow As Long, blnFound As Boolean strUsername = UserNameTB.Value strPassword = PasswordTB.Value With ActiveSheet lngLastRow = .Cells(Rows.Count, 1).End(xlUp).Row blnFound = False For i = 1 To lngLastRow If strUsername = .Cells(i, 1).Value Then If strPassword = .Cells(i, 2).Value Then blnFound = True Exit For Else MsgBox "Wrong Password!" Exit For End If End If Next If blnFound Then Select Case .Cells(i, 3).Value Case "N": Show TimesheetEntry Case "A": Show LoginOption End Select End If End With End Sub Rob "maxifire " wrote in message ... Hi Guys, I'm currently having troubles to fufill the 3 conditions in the if else statement which I have coded. This if-else statement is used in the password checking system where the usernames and passwords are all stored in a spreadsheet. Besides usernames and passwords, there are 2 groups where users belong to. They are 'A' - Administrators, and 'N' - Normal Users. In the if-else statement, I plan to code it in such a way that it will scan through the spreadsheet looking for the username and once it matches, it will offset by (0, 1) to compare the password. After which, the code should offset again to check for the usergroup so as to show a different menu between administrators and users. The following code which I coded, unfortunately does not work due to some reasons. :( Will be really grateful if someone could assist. Lastly, sorry for the wrong post. Regards, Kenneth --- Sub OkBtn_Click() Dim a As Integer Dim Name As String Dim Pass As String Dim Group As String Name = UserNameTB.Value Pass = PasswordTB.Value Cells(1, 1).Select For a = 1 To 20 If Name = ActiveCell.Value And Pass = ActiveCell.Offset(0, 1).Value Then GoTo GroupCompare MsgBox ("Wrong Password!") Next a Cells(1, 1).Select GroupCompa If ActiveCell.Offset(0, 2) = "N" Then Show TimesheetEntry ElseIf ActiveCell.Offset(0, 2) = "A" Then Show LoginOption End If End Sub --- --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
3 conditions if else statement.
Hi Rob,
Good to hear from you. Will try out the code and keep you informed Thanks once again! ;) Regards, Kennet -- Message posted from http://www.ExcelForum.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
If Statement On Two Conditions | Excel Worksheet Functions | |||
Need help with If-then statement with multiple conditions | Excel Worksheet Functions | |||
Nested if statement with over 7 conditions - VBA? | Excel Discussion (Misc queries) | |||
Conditions with IF statement | Excel Discussion (Misc queries) | |||
Nesting If Statement with "AND", "OR" conditions | Excel Worksheet Functions |