IF statement

drjpb

Board Regular
Joined
Dec 11, 2013
Messages
66
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I am trying to write an IF condition, first criteria is Column D,
If Column D Value is 3, then Result value should be 99006661001
If Column D Value is 9, then Result Value should be 52006881570
If Column D Value is 6 or 5, then second criteria is based on Column C (First 2 digits),
If first two digits of C is 11, then Result Value should be 010066743
If first two digits of C is 12, then Result Value should be 020066743
If first two digits of C is 13, then Result Value should be 030066743
If first two digits of C is 14, then Result Value should be 520066743
If first two digits of C is 15, then Result Value should be 050066743
If first two digits of C is 16, then Result Value should be 050066743

Now the problem i am facing is, with Column D value 5, why is it giving me False?


#ABCDEFG
1118585945FALSE
2118582756010066743
311857038399006661001
411858479952006881570
5616743046FALSE
6118543525FALSE
7118586226010066743
8118585205FALSE
9118581325FALSE
10118581246010066743
11623673476FALSE
12118584885FALSE
13118586986010066743
14631589206FALSE
15118586556010066743
16118585345FALSE

<tbody>
</tbody>



Here's my formula, typed in Range G2:
=IF(D2=3;"99006661001";(IF(D2=9;"52006881570";
(IF(D2=6;(IF(LEFT(C2;2)="11";"010066743";IF(LEFT(C2;2)="12";"020066743";
IF(LEFT(C2;2)="13";"030066743";IF(LEFT(C2;2)="14";"520066743";
IF(LEFT(C2;2)="15";"050066743";IF(LEFT(C2;2)="16";"050066743";
(IF(D2=5;(IF(LEFT(C2;2)="11";"010066743";IF(LEFT(C2;2)="12";
"020066743";IF(LEFT(C2;2)="13";"030066743";IF(LEFT(C2;2)="14";
"520066743";IF(LEFT(C2;2)="15";"050066743";IF(LEFT(C2;2)="16";
"050066743")))))))))))))))))))))


Will appreciate if my mistake is rectified.
Thanks in advance.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
you are onlytesting D2 for values of 3,9,6
(IF(D2=6;

You want to add
(IF(OR( D2=6; D2=5) ;
so that if D2 is 5 or a 6 you do the C column Test

its also false because you dont have a false value at the end

520066743";IF(LEFT(C2;2)="15";"050066743";IF(LEFT(C2;2)="16";
"050066743";"you need a value here or you get false")))))))))))))))))))))
 
Upvote 1
Hi

Or :-
Code:
=IF(D2=3;"99006661001";IF(D2=9;"52006881570";IF(OR(D2={5;6});IFERROR(INDEX({"010066743";"020066743";"030066743";"520066743";"050066743";"050066743"};;MATCH(LEFT(C2;2);{"11";"12";"13";"14";"15";"16"};0));FALSE))))

hth
 
Upvote 1
Hi drjpb,

Base on your requirements in post#1, this might be what you're looking for.
ps: Note that if none of the condition met you're end up with FALSE (as Wayne highlighted)
ps: Please replace all commas with semi-colons to match your settings

CDEFG
2118585945010066743
3118582756010066743
411857038399006661001
511858479952006881570
6616743046FALSE
7118543525010066743
8118586226010066743
9118585205010066743
10118581325010066743
11118581246010066743
12623673476FALSE
13118584885010066743
14118586986010066743
15631589206FALSE
16118586556010066743
17118585345010066743

<tbody>
</tbody>

Spreadsheet Formulas
CellFormula
G2=IF(D2=3,"99006661001",IF(D2=9,"52006881570",IF(OR(D2={5,6}),IF(LEFT(C2,2)="11","010066743",IF(LEFT(C2,2)="12","020066743",IF(LEFT(C2,2)="13","030066743",IF(LEFT(C2,2)="14","520066743",IF(OR(LEFT(C2,2)={"15","16"}),"050066743"))))))))

<tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
Solution
Good Morning DR, looks like Wayne beat me to it this morning, I am at work adn cant get the the table to copy and paste like I can at home. but Wayne is right if you consider changing your logic a bit how about a lookup table. with an IF(OR()) in it. I took your values and made a table from I1:J8 starting with

<tbody>
</tbody>
=IF(OR(D14=5,D14=6),VLOOKUP(LEFT(C14,2)*1,$I$1:$J$8,2,FALSE),IF(D14=3,$J$1,IF(D14=9,$J$2,"")))

3,9,11,12,13,14,15,16 in I and the rest of your desired results in K. you can alsways expand your range or change your results in the future without changing your formula.
 
Last edited:
Upvote 1
Thanks guys for all the solutions, and your efforts. I will try all tomorrow morning in office, and will post the results.
Once again thanking you for your care.
 
Upvote 0

Forum statistics

Threads
1,221,417
Messages
6,159,789
Members
451,589
Latest member
Harold14

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