Hello,
I'm wondering if it's possible to use the OR statement with Not Equal To (<>) in VBA.
I'm trying to simplify the user selection from a MsgBox to validate the entries and then Exit Sub if no valid matches were found, Else proceed with running the Macro.
Here's what I'm working with:
Note: I'm using a list of Student ID's, but I just wanted to test with some names to simplify the testing for now…
If I enter a valid name, or an invalid name, or hit Cancel... all result with an invalid or canceled entry response.
Any help would be greatly appreciated…
I'm wondering if it's possible to use the OR statement with Not Equal To (<>) in VBA.
I'm trying to simplify the user selection from a MsgBox to validate the entries and then Exit Sub if no valid matches were found, Else proceed with running the Macro.
Here's what I'm working with:
Note: I'm using a list of Student ID's, but I just wanted to test with some names to simplify the testing for now…
VBA Code:
Sub GetStudentName()[/FONT]
[FONT=Segoe UI]'Get Name
Dim Student As String
Student = Application.InputBox( _
"Enter Students Name to assign new books." & vbCrLf & _
"Click Cancel or leave blank to cancel.", "Copy New Books for...", "Enter student name")
Student = Application.WorksheetFunction.Proper(Student) 'Convert input to Propercase
'Validate Name
If Student <> "John" Or Student <> "Jane" Or cName = vbNullString Then
MsgBox "You selected Cancel, or entered an invalid name."
Exit Sub
Else
MsgBox "You entered " & Student
End If[/FONT]
[FONT=Segoe UI]End Sub[/FONT]
If I enter a valid name, or an invalid name, or hit Cancel... all result with an invalid or canceled entry response.
Any help would be greatly appreciated…