andrewb90
Well-known Member
- Joined
- Dec 16, 2009
- Messages
- 1,077
Hello All,
I have a code validation page setup. But on my sheet InGen I have a list of validation codes and their corresponding expiration dates. Now I could just do an elseif statement that matches the original if statement over and over again, but I was wondering if there is a far more elegant way of doing this?
Basically the codes run from row 4781 through 4791. So the first IF would be 4781, then the ElseIf would be 4782, the next ElseIf would be 4783, etc.
Is there a simple way of doing this?
I have a code validation page setup. But on my sheet InGen I have a list of validation codes and their corresponding expiration dates. Now I could just do an elseif statement that matches the original if statement over and over again, but I was wondering if there is a far more elegant way of doing this?
Basically the codes run from row 4781 through 4791. So the first IF would be 4781, then the ElseIf would be 4782, the next ElseIf would be 4783, etc.
Is there a simple way of doing this?
Code:
Private Sub validate()If Range("D6").Value = Sheets("InGen").Range("XAB4781") Then
If Now() > CDate(4 / 14 / 1912) And Now() < CDate(Sheets("InGen").Range("XAC4781")) Then
MsgBox "Your code has been accepted." & vbNewLine & vbNewLine & "Your Software is valid until " & Sheets("InGen").Range("XAC4781"), vbInformation, "The Code Validation Robot Says:"
Else:
MsgBox "Your code is not valid." & vbNewLine & "This code expired on " & Sheets("InGen").Range("XAC4780"), vbInformation, "The Code Validation Robot Says:"
End If
Else:
MsgBox "Your code is invalid." & vbNewLine & "Please check the code and try again." & vbNewLine & "Contact support with any issues.", vbInformation, "The Code Validation Robot Says:"
End If
End Sub