This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Please review attached file that explains the need. Thanks.

IfStatementsFormula.xlsx

IfStatementsFormula.xlsx

Based on your results, it seems you just want:

=IF(D3<>D4,1,0)

but your description is:

=IF(AND(D3<>D4,D4=D5),1,0)

1 D4 has nothing above so it doesn't equal but is the same D5

0 D5 is the same as D4 and the same as D6

0 D6 does match D5 but does not match D7

0 D7 Doesn't match D6 or D8

1 D8 does not match D7 but does match D8

0 D9 matches D8 but not D10

0 D10 doesn't match D9 or D11

0 D11 doesn't match D10 and nothing below

I can write the if statements independent of each other, where I am having the issue is putting them all into one formula, so it can copy it down. Thanks. -R-

need to add a line:

in other case: 1

without simplification it is:

=IF(AND(D4<>D3;D4=D5);1;IF

If this is true, then insert this formula in cell E4 and copy down:

Regards,

-Glenn

I updated the attachment.. with the added rule.

IfStatementsFormula2.xlsx

IfStatementsFormula2.xlsx

If the data in column D is not sorted and you still wanted to identify the first occurrence of a value in that column, the COUNTIF formula will do that.

-Glenn

The formula I provided is broken down like so:

The formula in cell E9, for example looks like this:

Since the COUNTIF function returns 2 here (because there are 2 "C" values at this point, the formula returns a zero.

But, as I noted, so long as your data in column D is sorted, Rory's formula is simpler (and faster).

But as I said, it can be simplified:

if you match TRUE==1 & FALSE == 0

IF(A;0;1) === not A

IF(A;1;0) === A

IF(A;1;B) === A or B

IF(A;0;B) === not A or B

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.

I still think you just want:

=IF(D3<>D4,1,0)

which produces the results you showed.