Home > OS >  Combining 6 IF formulas
Combining 6 IF formulas

Time:01-25

I've written 6 different IF formulas, each will identify a freight carrier based on the tracking number found in cell BM71.

For the life of me I cannot figure out how to combine these, any help would be appreciated.

=IF(AND(LEN(BM71)=18,LEFT(BM71,2)="1Z"), "UPS", "")
=IF(AND(LEN(BM71)=12,ISNUMBER(BM71)),"FedEx","")
=IF(AND(LEN(BM71)=10,ISNUMBER(BM71)),"DHL","")
=IF(AND(LEN(BM71)=11,LEFT(BM71,2)="06"), "Old Dominion", "")
=IF(AND(LEN(BM71)=9,LEFT(BM71,2)="00"), "Arcbest", "")
=IF(AND(LEN(BM71)=10,LEFT(BM71,2)="00"), "Averitt", "")

CodePudding user response:

With ifS function it gets more clean:

=IFs(AND(LEN(BM71)=18,LEFT(BM71,2)="1Z"), "UPS", 
AND(LEN(BM71)=12,ISNUMBER(BM71)),"FedEx",
AND(LEN(BM71)=10,ISNUMBER(BM71)),"DHL",
AND(LEN(BM71)=11,LEFT(BM71,2)="06"), "Old Dominion",
AND(LEN(BM71)=9,LEFT(BM71,2)="00"), "Arcbest",
AND(LEN(BM71)=10,LEFT(BM71,2)="00"), "Averitt")

CodePudding user response:

You just add a new IF in the False part. Like this:

=IF(AND(LEN(BM71)=18,LEFT(BM71,2)="1Z"), "UPS",
IF(AND(LEN(BM71)=12,ISNUMBER(BM71)),"FedEx",
IF(AND(LEN(BM71)=10,ISNUMBER(BM71)),"DHL",
IF(AND(LEN(BM71)=11,LEFT(BM71,2)="06"), "Old Dominion",
IF(AND(LEN(BM71)=9,LEFT(BM71,2)="00"), "Arcbest",
IF(AND(LEN(BM71)=10,LEFT(BM71,2)="00"), "Averitt", ""))))))

CodePudding user response:

You can add next one instead of "" of previous formula

=IF(AND(LEN(BM71)=18,LEFT(BM71,2)="1Z"), "UPS", IF(AND(LEN(BM71)=12,ISNUMBER(BM71)),"FedEx",IF(AND(LEN(BM71)=10,ISNUMBER(BM71)),"DHL",IF(AND(LEN(BM71)=11,LEFT(BM71,2)="06"), "Old Dominion", IF(AND(LEN(BM71)=9,LEFT(BM71,2)="00"), "Arcbest", IF(AND(LEN(BM71)=10,LEFT(BM71,2)="00"), "Averitt", ""))))))

However you approach to define something based on length and some chars is not stable I hope I could help you

  • Related