#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 18
Default Date Range Question

Assume there is a date range from 1/1 to 3/31 (i.e., first quarter).

In cell A2 I have a start date, in cell B2 I have an end date.

If the start date is greater than the end date
or the end date is less than the start date
or the dates are not within the date range
display "Date Error" in cell C3

Can someone help with a macro or formula for this problem?

Thanks in Advance
--
Rodman Veney
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,549
Default Date Range Question


Dates in A2:A91
Start Date in B2
End Date in C2
Message formula in D2
Min function for dates in E2
Max function for dates in F2

Formula in D2...
=IF(OR(B2< E2,B2F2,B2C2),"Start Date Error",IF(OR(C2<E2,C2F2,C2<B2),"End Date Error","OK"))
--
Jim Cone
Portland, Oregon USA



"Rodman"
wrote in message
Assume there is a date range from 1/1 to 3/31 (i.e., first quarter).
In cell A2 I have a start date, in cell B2 I have an end date.

If the start date is greater than the end date
or the end date is less than the start date
or the dates are not within the date range
display "Date Error" in cell C3

Can someone help with a macro or formula for this problem?
Thanks in Advance
--
Rodman Veney
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 915
Default Date Range Question

Rodman wrote:
Assume there is a date range from 1/1 to 3/31 (i.e., first quarter).

In cell A2 I have a start date, in cell B2 I have an end date.

If the start date is greater than the end date
or the end date is less than the start date
or the dates are not within the date range
display "Date Error" in cell C3

Can someone help with a macro or formula for this problem?

Thanks in Advance


So, you want to ensure both A2 and B2 are in the quarter?

=IF(OR(A2<DATE(2009,1,1),A2DATE(2009,3,31),B2<DAT E(2009,1,1),B2DATE(2009,3,31)),"Date
Error","No Date Error")
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 18
Default Date Range Question

Thanks! - This solution worked great!

now I have been asked to put the error message in the offending cell.

ex if cell A2 is outside of the date range the error message placed in cell
A2 coule be "#DER (for date error).

Thanks In Advance
--
Rodman Veney


"smartin" wrote:

Rodman wrote:
Assume there is a date range from 1/1 to 3/31 (i.e., first quarter).

In cell A2 I have a start date, in cell B2 I have an end date.

If the start date is greater than the end date
or the end date is less than the start date
or the dates are not within the date range
display "Date Error" in cell C3

Can someone help with a macro or formula for this problem?

Thanks in Advance


So, you want to ensure both A2 and B2 are in the quarter?

=IF(OR(A2<DATE(2009,1,1),A2DATE(2009,3,31),B2<DAT E(2009,1,1),B2DATE(2009,3,31)),"Date
Error","No Date Error")

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 915
Default Date Range Question

You do see where to put "#DER" in the formula I gave, yes?

=IF(OR(A2<DATE(2009,1,1),A2DATE(2009,3,31),B2<DAT E(2009,1,1),B2DATE(2009,3,31)),"Rodman's
Message Here","No Date Error")

Or did you mean something different?


Rodman wrote:
Thanks! - This solution worked great!

now I have been asked to put the error message in the offending cell.

ex if cell A2 is outside of the date range the error message placed in cell
A2 coule be "#DER (for date error).

Thanks In Advance



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 18
Default Date Range Question

Not Exactly...

In the sample being discussed if there was an error (i.e., the data not
within the range) an error would be displayed in cell C2. I would like to
put the error in the cell in which the error occurs. If, for example, the
date in cell A2 is not within the date range I would like to put the error
message #DER in that cell.

Additionally, I would like to make sure the start date is not greater than
the end date and the end date is not less than the start date (for that date
range). I think this will have to be a macro.

I have sucessfully used your example to make sure the dates are within thr
range but have not figured out how to determine the greater- than, less-than
date issue.

Regards,
--
Rodman Veney


"smartin" wrote:

You do see where to put "#DER" in the formula I gave, yes?

=IF(OR(A2<DATE(2009,1,1),A2DATE(2009,3,31),B2<DAT E(2009,1,1),B2DATE(2009,3,31)),"Rodman's
Message Here","No Date Error")

Or did you mean something different?


Rodman wrote:
Thanks! - This solution worked great!

now I have been asked to put the error message in the offending cell.

ex if cell A2 is outside of the date range the error message placed in cell
A2 coule be "#DER (for date error).

Thanks In Advance


  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 915
Default Date Range Question

Ah, sorry.

Well you can't replace the cell values (A2 & B2) with an error message
(well you could with VBA, but I think this is overkill). What you can do
easily is apply conditional formatting to the problem cells,
highlighting error values when they occur.

This will be easiest if you have the date limits (e.g., 1/1/2009 and
3/31/2009) is cells somewhere. Let's assume they are in Y1 and Z1,
respectively.

In A2 you want to check three things: A2<Y1, A2Z1 or A2B2 should all
throw an error. In A2, the conditional format expression would look like

Formula is: =OR(A2<Y1,A2Z1,A2B2)

Make the conditional format something vivid, like bold red font against
yellow shading.

The conditional format expression in B2 would be quite similar.

Hope this helps!


Rodman wrote:
Not Exactly...

In the sample being discussed if there was an error (i.e., the data not
within the range) an error would be displayed in cell C2. I would like to
put the error in the cell in which the error occurs. If, for example, the
date in cell A2 is not within the date range I would like to put the error
message #DER in that cell.

Additionally, I would like to make sure the start date is not greater than
the end date and the end date is not less than the start date (for that date
range). I think this will have to be a macro.

I have sucessfully used your example to make sure the dates are within thr
range but have not figured out how to determine the greater- than, less-than
date issue.

Regards,

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sum If range of dates date range, sum totals Stilmovin Excel Worksheet Functions 7 December 16th 08 05:49 PM
Question about using MIN/MAX, INDEX with Date range ML Srini Excel Worksheet Functions 3 October 4th 07 12:59 AM
Date Range Question elfmajesty Excel Discussion (Misc queries) 2 January 13th 06 01:50 PM
How to count dates within a certain range in a column with mutiple date range entries Krisjhn Excel Worksheet Functions 2 September 1st 05 01:59 PM
SUMPRODUCT with date range question Rob V Excel Discussion (Misc queries) 1 January 31st 05 03:55 PM


All times are GMT +1. The time now is 05:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"