Excel formula based on Date input

crave4excel

New Member
Joined
Feb 2, 2012
Messages
45
ABCDEFG
FromToJan 1Feb 1Mar 1Apr 1May 1
Feb 1Mar 15noyesyesnono
Feb 15Apr 30noyesyesyesno

<tbody>
</tbody>

Hello
I have a table similar to above. I want to come up with a formula to populate "yes" or "no" from column C3:G4, based on dates entered in column A:B (in red).

Any ideas?

Appreciated.
 
Last edited:

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hi,

If the Year is Not a factor:


Excel 2010
ABCDEFG
2FromTo1-Jan1-Feb1-Mar1-Apr1-May
31-Feb15-MarNoYesYesNoNo
415-Feb30-AprNoYesYesYesNo
Sheet6
Cell Formulas
RangeFormula
C3=IF(AND(MONTH(C$2)>=MONTH($A3),MONTH(C$2)<=MONTH($B3)),"Yes","No")


C3 formula copied down and across.
 
Upvote 0
What about something like this in cell C2:

Code:
=IF(AND(C1>=$A2,C1<=$B2),"Yes","No")

That would fail for comparing D2 on Row 4, as both dates are in the Same month, but D2 is Feb-1, and A4 is Feb-15.
According to OP's sample, he/she is comparing the Month.
 
Last edited:
Upvote 0
Hi,

If the Year is Not a factor:

Excel 2010
ABCDEFG
2FromTo1-Jan1-Feb1-Mar1-Apr1-May
31-Feb15-MarNoYesYesNoNo
415-Feb30-AprNoYesYesYesNo

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet6

Worksheet Formulas
CellFormula
C3=IF(AND(MONTH(C$2)>=MONTH($A3),MONTH(C$2)<=MONTH($B3)),"Yes","No")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>



C3 formula copied down and across.

Thanks. that didn't work but I think it's because my example was bad. Here's the modified example:
fromtoApr 9April 16april 23april 30may 7
apr 17apr 30noyesyesyesno

<tbody>
</tbody>
 
Upvote 0
Thanks. that didn't work but I think it's because my example was bad. Here's the modified example:
from
to
Apr 9
April 16
april 23
april 30
may 7
apr 17
apr 30
no
yes
yes
yes
no

<tbody>
</tbody>

At first glance, I was going to say, "Then, use Jimbo's formula in Post #3 , since now you're comparing the actual Date, Not just the Month".
But, then I saw "Yes" under April 16, Why is that?
 
Upvote 0
Thanks for the question. Because April 17 is between Apr 16 - Apr 23, so i'm essentially comparing "the week of".

So I want to show "yes" to wherever the set of dates fall under, hence, April 17 - 30 fall under the week of Apr 16 through week of April 30
 
Last edited:
Upvote 0
Now I'm confused, your "from" and "to" dates in your latest sample, are they From Apr 17 To Apr 30? or something else?
 
Upvote 0
yes, from Apr 17 to APr 30. So i want to highlight the date range these dates fall under. So ..

Week of April 9 : no because the week ends on the 15th
Week of April 16: yes because april 17 falls under this week
Week of April 23: yes
Week of April 30: the end date of the range is the 30th, hence falls under this week
Week of May 7: falls outside the date range, so "no"
 
Upvote 0
yes, from Apr 17 to APr 30. So i want to highlight the date range these dates fall under. So ..

Week of April 9 : no because the week ends on the 15th
Week of April 16: yes because april 17 falls under this week
Week of April 23: yes
Week of April 30: the end date of the range is the 30th, hence falls under this week
Week of May 7: falls outside the date range, so "no"

If I understand correctly, Now you're comparing the Week?
This will work, I'm using the "Default", where Sunday is the beginning of each week.


Excel 2010
ABCDEFG
1fromto9-Apr16-Apr23-Apr30-Apr7-May
217-Apr30-AprNoYesYesYesNo
Sheet6
Cell Formulas
RangeFormula
C2=IF(AND(WEEKNUM(C$1)>=WEEKNUM($A2),WEEKNUM(C$1)<=WEEKNUM($B2)),"Yes","No")
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

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