Help with IF statement

it's an excel world

Board Regular
Joined
Sep 17, 2008
Messages
126
I am looking for the most efficient way to write an if statement in cell E2 that looks in cell D2 for the following.

If left D2,5 = "25201" then "25201"
If left D2,2 = "1B"" then "25201"
If left D2,5 = "25856" then "25856"
If left D2,2 = "RD" then "25856"
If left D2,5 = "25882" then "25882"
If left D2,2 = "RT" then "25882"
Otherwise = "" (blank)

Thanks in advance!!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
That is what I normally do, but I am training someone new on this project and thought it might simplify the process if they performed the VLOOKUP where they just look at the 25201, 25856 & 25882. I really didn't feel comfortable with them filtering the VLOOKUP using the data in column D. There are several dozen unique values that start with 1B, 25201, etc.
 
Upvote 0
I am looking for the most efficient way to write an if statement in cell E2 that looks in cell D2 for the following.

If left D2,5 = "25201" then "25201"
If left D2,2 = "1B"" then "25201"
If left D2,5 = "25856" then "25856"
If left D2,2 = "RD" then "25856"
If left D2,5 = "25882" then "25882"
If left D2,2 = "RT" then "25882"
Otherwise = "" (blank)

Thanks in advance!!

Try...
Code:
=LOOKUP(REPT("z",255),CHOOSE({1,2,3},
    "",
    VLOOKUP(LEFT(D2,5),{"25201";"25856";25882},1,0),
    VLOOKUP(LEFT(D2,2),{"1B","25201";"RD","25856";"RT","25882"},2,0)))
 
Upvote 0
=if(or(left(D2,5)="25201",left(D2,2)="1B"),"25201",if(or(left(D2,5)="25856",left(D2,2)="RD"),"25856",If(or(left(D2,5)="25882",left(D2,2)="RT"),"25882","")))

That should do it
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,865
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top