Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I know this question has been already asked a few times, but every statement that I try I end up with error messages.

I need a simple excel if statement where I can try out 3 possibilities:

Dates

I need to check 3 date columns, A1, B1 and C1. If all 3 are fullfilled, I need to subtract either C1 or B1 by A1. If B1 is empty, then I need to subtract C1 by A1. If C1 is empty, then I need to subtract B1 by A1. By all other results I need 0 to be returned.

Can anyone help me with that? I'm using excel 2016.

I tried the following statement: =IF(B2<>"";B2;C2)-A2

But it doesn't really cover all cases.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
129 views
Welcome To Ask or Share your Answers For Others

1 Answer

Same result for sample as accepted 'Excel Version' A except for all 3 are fullfilled case:

=IF(A1="",0,MAX(A1:C1)-MAX(MIN(A1:C1),0))

Assumes Brazilian date formats.

Whatever the garbled English is supposed to mean (there is an SE site for a Portuguese version of SO) the results of the first two rows are not required to be the same:

The second row of the example is blank for (I assume, since OP has not bothered to clarify cell references) C1, hence:

If C1 is empty, then I need to subtract B1 by A1

The first row is however populated in all three cells, hence:

If all 3 are fullfilled, I need to subtract either C1 or B1 by A1

In the first row (and indeed all rows in the sample) B1 and A1 are not the same. So for that row there are two different results, which therefore cannot both be the same as any other (single) result, such as whatever is the result for the second row.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...