Compare the difference between 3 dates, 1 of which is optional

meaningofexcel

New Member
Joined
Jul 25, 2018
Messages
9
Hi,

I have a conditional formatting formula that "paints" the cell of a gantt chart start and end dates. I'm introducing Travel date to the equation but this date is optional, sometimes it's empty, sometime it's not.

How can I build this formula to look at the travel date as well if it exists?
Column H is Travel Date; Column I is Start Date, Column J is End Date.

For comparing 2 dates my formula was:
=and(AC$2>=$I3,AC$2<=$J3)


I tried this for 3 dates but it doesn't work:
=AND(AC$2>=$H3, OR(AC$2>=$I3),AC$2<=$J3)


Thank you.
 

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.
Maybe
=AND($AC$2>=$H3,$H3<>"", OR($AC$2>=$I3),$AC$2<=$J3)


Hm.

First, since this is a conditional formatting function, the rows are not absolute, so I tried the formula you have mentioned without $:

=AND(AC$2>=$H3,$H3<>"", OR(AC$2>=$I3),AC$2<=$J3)

This basically colors only the cells(rows) that have a travel date now. Everything else is blank.
It looks like you just added a "if H3 is not empty" without specifying - "if H3 is not empty take value from H3 instead of I3, if It's empty, take value from I3.
 
Last edited:
Upvote 0
Ha,

Looks like typing what I'm trying to achieve actually helped me think of the correct formula:


=IF($H3<>"", and(AC$2>=$H3,AC$2<=$J3), and(AC$2>=$I3,AC$2<=$J3))



Thank you!
 
Last edited:
Upvote 0
You didn't specify that's what you wanted ;)


Actually I did :) but I realize that I did not explain my situation clearly.

"How can I build this formula to look at the travel date as well if it exists?"

Thanks for replying!

Take care
 
Last edited:
Upvote 0
I thought you had that sorted.
If not can you please post some data showing what you have & how you would like it to look.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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

Which adblocker are you using?

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
Back
Top