SOLVED

Formula with Date Ranges

%3CLINGO-SUB%20id%3D%22lingo-sub-1756338%22%20slang%3D%22en-US%22%3EFormula%20with%20Date%20Ranges%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1756338%22%20slang%3D%22en-US%22%3E%3CP%3EI%20would%20like%20for%20an%20%22X%22%20to%20appear%20in%20a%20cell%20when%20certain%20date%20ranges%20are%20entered%20in%20another%20cell.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20currently%20have%20a%20formula%20for%20the%20X%20to%20appear%20when%20the%20date%20range%2010%2F19%2F2020%20-%2010%2F25%2F2020%20is%20entered%2C%20but%20I%20don't%20know%20how%20to%20add%20multiple%20date%20ranges%20to%20the%20formula.%20The%20current%20formula%20I%20have%20is%3A%3CBR%20%2F%3E%3DIF(AND(%24BK%244%26gt%3B%3DDATEVALUE(%2210%2F19%2F2020%22)%2C%24BK%244%26lt%3B%3DDATEVALUE(%2210%2F25%2F2020%22))%2C%22X%22%2C%22%22)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20need%20to%20add%20a%20few%20more%20date%20ranges%2C%20one%20including%2011%2F01%2F2020%20-%2011%2F06%2F2020.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1756338%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1757159%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20with%20Date%20Ranges%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1757159%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F824136%22%20target%3D%22_blank%22%3E%40taylorcobaugh%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3ETry%20this%20one%3A%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DIF(OR(AND(A1%26gt%3B%3DDATEVALUE(%2210%2F19%2F2020%22)%2C%20A1%26lt%3B%3DDATEVALUE(%2210%2F25%2F2020%22))%2C%20AND(A1%26gt%3B%3DDATEVALUE(%2211%2F01%2F2020%22)%2C%20A1%26lt%3B%3DDATEVALUE(%2211%2F06%2F2020%22)))%2C%22x%22%2C%22%22)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3EYou%20may%20extend%20the%20formula%20for%20more%20dates.%3C%2FLI%3E%3CLI%3EAdjust%20dates%20%26amp%3B%20cell%20references%20in%20the%20formula%20as%20needed.%3C%2FLI%3E%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1757326%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20with%20Date%20Ranges%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1757326%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F824136%22%20target%3D%22_blank%22%3E%40taylorcobaugh%3C%2FA%3E%26nbsp%3BAs%20a%20variant%2C%20have%20a%20look%20at%20the%20attached%20workbook.%20Include%20the%20star%20and%20end%20dates%20in%20two%20named%20ranges%20(start%20and%20end)%20and%20use%20a%20formula%20like%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DIF(SUM((A10%26gt%3B%3Dstart)*(A10%26lt%3B%3Dend))%2C%22X%22%2C%22%22)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3Bwhere%20A10%20holds%20the%20date%20you%20want%20to%20test.%20No%20need%20for%20nested%20IFS%20and%20particularly%20handy%20when%20you%20need%20to%20add%20more%20than%20just%20a%20few%20date%20ranges.%20Obviously%2C%20your%20dates%20have%20to%20be%20real%20dates%2C%20not%20texts%20looking%20like%20dates.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1757366%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20with%20Date%20Ranges%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1757366%22%20slang%3D%22en-US%22%3EYour%20formula%20needs%20little%20correction%2C%2C%2C%20and%20it%20must%20be%20an%20array%20(CSE)%20formula%2C%20need%20to%20finish%20with%20Ctrl%2BShift%2BEnter%2C%2C%20otherwise%20you%20get%20%23VALUE%20error%20!!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1757397%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20with%20Date%20Ranges%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1757397%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F93699%22%20target%3D%22_blank%22%3E%40Rajesh-S%3C%2FA%3E%26nbsp%3BAll%20depends%20on%20your%20Excel%20version.%20I'm%20on%20the%20most%20recent%20one%20and%20CSE%20is%20never%20an%20issue.%20It%20is%20my%20understanding%20that%20Excel%20silently%20converts%20such%20formulae%20to%20CSE%20style%20in%20older%20versions.%20But%20perhaps%20I'm%20mistaken.%20Then%2C%20indeed%2C%20such%20formulae%20should%20be%20entered%20with%20CSE.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1758582%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20with%20Date%20Ranges%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1758582%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3B%2C%2C%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20are%20talking%20about%20this%20%3DArrayFormula(SUM(A1%3AA5%20*%20B1%3AB5))%20then%2C%20this%20happens%20in%20Google%20Sheet%20only%2C%2C%2C%20where%20user%20has%20to%20use%20either%20%22ArrayFormula%22%20the%20reserve%20word%20or%20even%20executes%20CSE%20%2C%2C%20Google%20Sheet%20adds%20ArrayFormula%20with%20the%20formula!!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWith%20Excel%202016%2C%202019%20%26amp%3B%20365%20Dynamic%20array%20formula%20has%20been%20introduced%20but%20list%20is%20very%20small%20and%20doesn't%20covers%20the%20formula%20U%20have%20used.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20check%20the%20File%20you%20have%20uploaded%20%2C%2C%2C%2C%20I've%20examined%20and%20returning%20to%20you%20%2C%2C%2C%20no%20where%20I%20found%20EXCEL%20automatically%20applied%26nbsp%3B%20CSE%20%2C%2C%2C%20Ctrl%2BShift%2BEnter%20!!%26nbsp%3B%20And%20I've%20opened%20it%20with%202013.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1760496%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20with%20Date%20Ranges%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1760496%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F93699%22%20target%3D%22_blank%22%3E%40Rajesh-S%3C%2FA%3E%26nbsp%3BThank%20you%20this%20answer%20did%20work.%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20I%20need%20to%20figure%20out%20how%20the%20formula%20for%20when%20multiple%20different%20date%20ranges%20produce%20different%20responses.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EExample%3A%3C%2FP%3E%3CP%3EI%20want%20for%20the%20date%20range%20of%2010%2F19%2F2020%20-%2010%2F25%2F2020%20to%20produce%2011%20in%20one%20cell.%3C%2FP%3E%3CP%3EAnd%20when%20the%20date%20range%20is%2010%2F26%2F2020%20-%2011%2F01%2F2020%2C%20I%20want%20it%20to%20produce%2018%20in%20the%20cell.%3C%2FP%3E%3CP%3EThen%20when%20the%20date%20range%20is%2011%2F02%2F2020%20-%2011%2F08%2F2020%2C%20I%20want%20it%20to%20produce%2025%20in%20the%20cell.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20you%20help%20me%20with%20this%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1761146%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20with%20Date%20Ranges%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1761146%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F824136%22%20target%3D%22_blank%22%3E%40taylorcobaugh%3C%2FA%3E%26nbsp%3BOh%2C%20you%20change%20the%20rules%20a%20bit%20now%2C%20but%20that%20can%20be%20dealt%20with.%20See%20attached%20(in%20the%20green%20shaded%20area).%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

I would like for an "X" to appear in a cell when certain date ranges are entered in another cell.

 

I currently have a formula for the X to appear when the date range 10/19/2020 - 10/25/2020 is entered, but I don't know how to add multiple date ranges to the formula. The current formula I have is:
=IF(AND($BK$4>=DATEVALUE("10/19/2020"),$BK$4<=DATEVALUE("10/25/2020")),"X","")

 

I need to add a few more date ranges, one including 11/01/2020 - 11/06/2020.

13 Replies
Highlighted
Best Response confirmed by taylorcobaugh (Occasional Contributor)
Solution

@taylorcobaugh 

 

Try this one:

 

=IF(OR(AND(A1>=DATEVALUE("10/19/2020"), A1<=DATEVALUE("10/25/2020")), AND(A1>=DATEVALUE("11/01/2020"), A1<=DATEVALUE("11/06/2020"))),"x","")

 

  • You may extend the formula for more dates.
  • Adjust dates & cell references in the formula as needed.
Highlighted

@taylorcobaugh As a variant, have a look at the attached workbook. Include the star and end dates in two named ranges (start and end) and use a formula like:

=IF(SUM((A10>=start)*(A10<=end)),"X","")

 where A10 holds the date you want to test. No need for nested IFS and particularly handy when you need to add more than just a few date ranges. Obviously, your dates have to be real dates, not texts looking like dates.

Highlighted
Your formula needs little correction,,, and it must be an array (CSE) formula, need to finish with Ctrl+Shift+Enter,, otherwise you get #VALUE error !!
Highlighted

@Rajesh-S All depends on your Excel version. I'm on the most recent one and CSE is never an issue. It is my understanding that Excel silently converts such formulae to CSE style in older versions. But perhaps I'm mistaken. Then, indeed, such formulae should be entered with CSE.

Highlighted

@Riny_van_Eekelen ,,,

 

If you are talking about this =ArrayFormula(SUM(A1:A5 * B1:B5)) then, this happens in Google Sheet only,,, where user has to use either "ArrayFormula" the reserve word or even executes CSE ,, Google Sheet adds ArrayFormula with the formula!!

 

With Excel 2016, 2019 & 365 Dynamic array formula has been introduced but list is very small and doesn't covers the formula U have used.

 

Now check the File you have uploaded ,,,, I've examined and returning to you ,,, no where I found EXCEL automatically applied  CSE ,,, Ctrl+Shift+Enter !!  And I've opened it with 2013.

Highlighted

@Rajesh-S Thank you this answer did work. 

Now I need to figure out how the formula for when multiple different date ranges produce different responses.

 

Example:

I want for the date range of 10/19/2020 - 10/25/2020 to produce 11 in one cell.

And when the date range is 10/26/2020 - 11/01/2020, I want it to produce 18 in the cell.

Then when the date range is 11/02/2020 - 11/08/2020, I want it to produce 25 in the cell.

 

Can you help me with this?

Highlighted

@taylorcobaugh Oh, you change the rules a bit now, but that can be dealt with. See attached (in the green shaded area).

Highlighted

@Riny_van_Eekelen 

Thank you for sending that over. I think that the situation I have is a bit different.

I attached my document, it is the first tab titled "WE 8-17".

 

There is one spot where a user can enter the date, and if that date falls within certain date ranges, I want a certain number to appear.

 

So every time someone types in a date to a new week, the dates in Row 10 change to next week's dates.

I hope this makes sense.

Highlighted

@taylorcobaugh 

Someone might well have suggested a table to contain the date ranges (I haven't opened all the files)

 
 

image.png

If you wish to return IDs for the ranges then the formula extends to

 

 

= IFERROR( 
  IF(LOOKUP(date, startRange, endRange) >= date, 
     LOOKUP(date, startRange, rangeID), 
     "-" ), 
  "-")

 

 

replacing the "X" by a further lookup.

 

Highlighted

@taylorcobaugh 

 

You may use this:

=IF(AND(A1>=DATE(2020,10,19),A1<=DATE(2020,10,25)),11,IF(AND(A1>=DATE(2020,10,26),A1<=DATE(2020,11,1)),18,IF(AND(A1>=DATE(2020,11,2),A1<=DATE(2020,11,8)),25,0)))

 

  • Adjust dates & cell references in the formula as needed.
Highlighted
Glad to help you,,, keep asking ☺
Highlighted

@taylorcobaugh 

If i have a number, like 3 in a cell, then a want a particular formula for occur for three years, if if have a 4 in a particular cell i would like another particular formula to occur in this cell.  How do I do this?

 

Jim

Highlighted

@Jim-Swan 

As variant you may use IF() or CHOOSE() or like, but depends on what exactly do you mean.