# of days outside of range

virtuosok

Board Regular
Joined
Sep 2, 2020
Messages
209
Office Version
  1. 365
Platform
  1. Windows
Hi,
I have two dates - these are B2 and D2 below. The expectation is that a specific event should happen in-between them, but it may also occur outside of this range. Just as a FYI, C2 serves as a reference, a mid point between these two extremes and can essentially be ignored.
Can you help me with the formula for cell C4 which would calculate how many days (if any) outside of the B2...D2 range the actual date in C3 is? In the example below, this is +3 days, but it can be -10 days, ideally the formula should preserve the "minus" or "plus" sign. Alternatively, the date in C3 can be within the B2-D2 window, in which case it would be nice for the formula to return "OK"...
ABCD
1 HeadersThe earliest allowed dateExpected dateThe latest allowed date
2 Dates scheduled01-Sep-2004-Sep-2007-Sep-20
3 Date actual-----------blank------------10-Sep-20--------------blank--------------
4 Difference-----------blank------------+3--------------blank--------------
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try:

Book1
ABCD
1HeadersThe earliest allowed dateExpected dateThe latest allowed date
2Dates scheduled1-Sep-204-Sep-207-Sep-20
3Date actual10-Sep-20
4Difference+3
Sheet10
Cell Formulas
RangeFormula
C4C4=IF(C3<B2,C3-B2,IF(C3>D2,C3-D2,"OK"))


I used a custom format of "+"0;"-"0 in C4 to preserve the sign.
 
Upvote 0
Thanks Eric W,
This works well! I like your solution on custom format :)
The only remaining (relatively minor) issue is that if there's no entry in C3, I'm getting -44095 in C4. If would be best if it were blank, or N/A....
 
Upvote 0

Forum statistics

Threads
1,214,628
Messages
6,120,618
Members
448,973
Latest member
ChristineC

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