# if function help

#### lrkfam

##### New Member
i need the if function to work as follows:

<d3<d4,ae1+af1,ag1)

if d2 is less than d3 and d3 is less than d4, if true then add ae1 to af1, if false then show the value from cell af1

it doesn't seem to work. what can i do to get the results i want?</d3<d4,ae1+af1,ag1)

Last edited:

##### MrExcel MVP
i need the if function to work as follows:

<D3<D4,AE1+AF1,AG1)< p>

if d2 is less than d3 and d3 is less than d4, if true then add ae1 to af1, if false then show the value from cell af1

it doesn't seem to work. what can i do to get the results i want?</D3<D4,AE1+AF1,AG1)< p>

Not sure whether your specifications are complete. Does the following...

=IF(AND(COUNT(D2:D4)=3, D2 < D3, D3 < D4), SUM(AE1:AF1), AF1)

works for you?

#### T. Valko

##### Well-known Member
i need the if function to work as follows:

<D3<D4,AE1+AF1,AG1)< p>

if d2 is less than d3 and d3 is less than d4, if true then add ae1 to af1, if false then show the value from cell af1

it doesn't seem to work. what can i do to get the results i want?</D3<D4,AE1+AF1,AG1)< p>

=IF(AND(D2 < D3, D3 < D4),AE1+AF1,AF1)<D3,D3<D4),AE1+AF1,AF1)< p>

#### lrkfam

##### New Member
=IF(AND(D2 < D3, D3 < D4),AJ2+AE2,AK2)

i tried this one, but i get the same result as before using:

=if(d2<d3<d4,aj2+ae2,ak2)

i'm trying the other one now

#### lrkfam

##### New Member
ok. i think i got it to work now. not sure what the problem was before.

=IF(AND(D3 < D4, D4 < D5),AJ2-AE2,AK2)

seems to work perfectly for now. thanx!!!

#### T. Valko

##### Well-known Member
ok. i think i got it to work now. not sure what the problem was before.

=IF(AND(D3 < D4, D4 < D5),AJ2-AE2,AK2)

seems to work perfectly for now. thanx!!!
You're welcome. Thanks for the feedback!