IF(AND) problem

Peesey

New Member
Joined
Nov 21, 2016
Messages
6
I am trying to use an IF(AND) to return a value if a cell on a calendar falls between two dates. The formula I'm using is: =IF(AND(D$1 >= $B2,D$1 <= $C2),$A2,"").

In the table below I want D2 to have the Ref number from A2 in it as the launch date in B2 falls in that week. However, it is coming back blank. If I change the launch date in B2 to match D1 (i.e. to 02/01/2017) it populates D2.

I've shown examples below to show what I mean:

Table showing the formulas used:


ABCDEFGHIJ
1Ref numberLaunch dateEnd date02-Jan09-Jan16-Jan23-Jan30-Jan06-Feb13-Feb
2ABC00103/01/201731/01/2017=IF(AND(D$1 >= $B2,D$1 <= $C2),$A2,"")=IF(AND(E$1 >= $B2,E$1 <= $C2),$A2,"")=IF(AND(F$1 >= $B2,F$1 <= $C2),$A2,"")=IF(AND(G$1 >= $B2,G$1 <= $C2),$A2,"")=IF(AND(H$1 >= $B2,H$1 <= $C2),$A2,"")=IF(AND(I$1 >= $B2,I$1 <= $C2),$A2,"")=IF(AND(J$1 >= $B2,J$1 <= $C2),$A2,"")

<tbody>
</tbody>

Table showing the result I get:

ABCDEFGHIJ
1Ref numberLaunch dateEnd date02-Jan09-Jan16-Jan23-Jan30-Jan06-Feb13-Feb
2ABC00103/01/201731/01/2017ABC001ABC001ABC001ABC001

<tbody>
</tbody>

Table showing the result I want:

ABCDEFGHIJ
1Ref numberLaunch dateEnd date02-Jan09-Jan16-Jan23-Jan30-Jan06-Feb13-Feb
2ABC00103/01/201731/01/2017ABC001ABC001ABC001ABC001ABC001

<tbody>
</tbody>

Basically, if the launch date is in a week I want the cell that corresponds to that week to be populated with the Ref number as well (regardless of the day in the week it launches - NOT just if it launched on the first day of the week).

Please help!!!
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Sorry - should have formatted them in the same way to make it clear but, yes they are all in 2017 - it is the week commencing date.
 
Upvote 0
Is this what you need?

=IF(AND(D$1>=$B2+1-WEEKDAY($B2,2),D$1<=$C2+7-WEEKDAY($C2,2)),$A2,"")
 
Last edited:
Upvote 0
Thanks Tetra201 but still not quite working. It solved my initial problem but the cell now remains populated if B2 is the start date of the following week (e.g. if I set B2 as 09/01/2017 cell D2 contains the Ref number when is should now be blank - this stops if I set B2 to 10/01/2017).
 
Upvote 0
The formula seems to work as posted.

Note: it was corrected within a few minutes of the initial posting -- I inadvertently copied a non-final formula from my test sheet. Please make sure you are using the current version.
 
Upvote 0

Forum statistics

Threads
1,214,813
Messages
6,121,706
Members
449,049
Latest member
THMarana

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