#1
|
|||
|
|||
If statement not working
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 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 |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
IF Statement not working | shawn.low@cox.net | Mail Merge | 3 | 02-27-2020 02:54 PM |
Converting a Select statement in Excel to an update statement | shabbaranks | Excel Programming | 5 | 10-31-2018 11:47 PM |
Tasks Switch to Non-Working Days on Working Calendar | danelloc | Project | 3 | 10-02-2017 12:38 PM |
IF Statement | Lkh1004 | Excel | 3 | 12-16-2015 02:47 PM |
Help with IF statement! | CPelkey | Word | 1 | 04-12-2010 09:06 AM |