# Choosing a date based on multiple criteria

#### omf_24

##### New Member

If the code is 03, 04, or 05, I want the result to be the later date of Date 3 or Date 2, otherwise I would want the earlier date to appear. If both are blank then Date 1 should be used.

 Code Date 1 Date 2 Date 3 Result A1 6/11/2013 2/5/2014 3/15/2013 3/15/2013 05 6/25/2013 1/17/2014 5/21/2014 5/21/2014 04 11/13/2012 11/13/2012 07 12/18/2012 1/17/2013 1/17/2013

<tbody>
</tbody>

### Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

#### ztodd

##### Board Regular
untested:
=if(and(c2="",d2=""),b2,if(or(a2="03",a2="04",a2="05"),max(d2,c2),min(d2,c2)))

#### ProfessorPorcupine

##### Board Regular
Try this, it is pretty long but I think it works ok: =IF(AND(C3=0,D3=0),B3,IF(OR(A3="03",A3="04",A3="05"),IF(D3>C3,D3,C3),IF(AND(C3<B3,C3<>0),C3,IF(AND(D3<C3,D3<>0),D3,C3))))

#### omf_24

##### New Member
untested:
=if(and(c2="",d2=""),b2,if(or(a2="03",a2="04",a2="05"),max(d2,c2),min(d2,c2)))

Thanks, this is working great if the code is 03, 04, or 05, but not if it's anything other than 03, 04, or 05. In that case it should be returning the earlier date rather than the later date.

#### omf_24

##### New Member

Try this, it is pretty long but I think it works ok: =IF(AND(C3=0,D3=0),B3,IF(OR(A3="03",A3="04",A3="05"),IF(D3>C3,D3,C3),IF(AND(C3<b3,c3<>0),C3,IF(AND(D3<c3,d3<>0),D3,C3))))

Sorry, but why cell's C30, and D30? </c3,d3<></b3,c3<>

#### omf_24

##### New Member
Thanks, this is working great if the code is 03, 04, or 05, but not if it's anything other than 03, 04, or 05. In that case it should be returning the earlier date rather than the later date.

Sorry, this is working correctly, thanks again!

you're welcome.

Replies
4
Views
65
Replies
2
Views
52
Replies
3
Views
143
Replies
17
Views
243
Replies
2
Views
38