Having issues getting this if statement to work. this is a snippet of a series of if statements trying to sort first and last name into alphabetical ranges. The hard part is sometimes a last name range is divided further by first name.. i.e. one range could be from a to b. johnson and the next range would pick up from c. johnson to m. nelson... etc.
This is the first instance in the if sequence where I have to sort by first name and i'm it's not catching for me no matter what i try although the other match in this section works.
I've created a variable to capture first and last name already and using the TRIM funciton and the FORMAT function to set proper case so that the names are caps. here's what I have so far (mind you everything else works find up to this point)
Code:
If (lastName >= "F*" And lastName <= "Garza") Then
If (lastName = "Garza" And firstName <= "M*") Then
ActiveSheet.Range("P10").Value = "Match 3 Successful"
ElseIf (lastName >= "F*" And lastName < "Garza") Then
ActiveSheet.Range("P10").Value = "Match 3 Successful"
End If
End If
for reference here's the entire if chain
Code:
If (lastName >= "A*" And lastName <= "Cap*") Then
ActiveSheet.Range("P10").Value = "Match 1 Successful"
End If
If (lastName >= "Caq*" And lastName <= "E*") Then
ActiveSheet.Range("P10").Value = "Match 2 Successful"
End If
If (lastName >= "F*" And lastName <= "Garza") Then
If (lastName = "Garza" And firstName <= "M*") Then
ActiveSheet.Range("P10").Value = "Match 3 Successful"
ElseIf (lastName >= "F*" And lastName < "Garza") Then
ActiveSheet.Range("P10").Value = "Match 3 Successful"
End If
End If
Can anyone offer up some help for me please, i've given myself a headache trying to figure it out.