# IF Formula

#### refpj2000

##### New Member
Excel 2007
Windows Vista
If number in cell A1= 1 and cell A2= 1,
if A1 is greater than A2, return, 3
if A1=A2 and is 1 or greater, return, 2
if A1=A2 and is less than, return, 1
if not return, 0
therefore value in a3 should be two
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
If Number in A1=2 A2= 1
therefore value in a3 should be 3
If Number in A1=0 A2= 0
therefore value in a3 should be 1
If Number in A1=1 A2= 2
therefore value in a3 should be 0

Using =if(ISBLANK(a1),0,IF(a1>a2,3,IF(a1,1,0)))
but can't workout how to add if A1=A2 and is 1 or greater, return, 2
Any help greatly appreciated.

Thanks

Pat

### Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

#### barry houdini

##### MrExcel MVP
Hello Pat, welcome to MrExcel

Try this formula

=IF(COUNT(A1:A2)=2,IF(A1>A2,3,IF(A1=A2,IF(A1>=1,2,1))))+0

#### refpj2000

##### New Member
Thanks Barry for your quick response.

Tried the formula result was 0, as opposed 2.

Many thanks again

Pat

#### barry houdini

##### MrExcel MVP
Tried the formula result was 0, as opposed 2.

For what values? If I put 1 in A1 and 1 in A2 I get 2 as required.

Do A1 and A2 contain formulas or are you just entering values?

#### refpj2000

##### New Member
Barry,

Sorry, worked a treat, my typo mistake.

More haste less speed on my part!

Many thanks

Pat

#### Using_Excel

##### New Member
I think nested if also will work;
=IF(A1>A2;3;IF(AND(A1=A2;A1>=1);2;IF(AND(A1=A2;A1<1;A1>0);1;0)))

Thank you.

Pat

Replies
5
Views
64
Replies
6
Views
51
Replies
11
Views
318
Replies
8
Views
74
Replies
5
Views
151

Threads
1,191,555
Messages
5,987,257
Members
440,086
Latest member
Mahi786

### 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

### 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