Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-13-2021, 10:19 AM
Javi78503 Javi78503 is offline If statement not working Windows 10 If statement not working Office 2019
Novice
If statement not working
 
Join Date: Jul 2021
Posts: 8
Javi78503 is on a distinguished road
Default 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
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.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
If statement not working 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 not working IF Statement Lkh1004 Excel 3 12-16-2015 02:47 PM
If statement not working Help with IF statement! CPelkey Word 1 04-12-2010 09:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:00 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft