Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If Statement On Two Conditions RoadKill Excel Worksheet Functions 5 July 28th 08 06:57 PM
Need help with If-then statement with multiple conditions Julie Excel Worksheet Functions 7 May 28th 08 09:15 AM
Nested if statement with over 7 conditions - VBA? Isa Excel Discussion (Misc queries) 2 January 19th 07 08:41 PM
Conditions with IF statement Jaydubs Excel Discussion (Misc queries) 2 June 26th 06 05:45 PM
Nesting If Statement with "AND", "OR" conditions Jenna Excel Worksheet Functions 3 October 30th 04 07:46 PM


All times are GMT +1. The time now is 07:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"