RANDARRAY Date Formula Issues

WhatTheF

New Member
Joined
Feb 25, 2025
Messages
17
Office Version
  1. 2021
Platform
  1. Windows
I'm truly grateful for all the help I've received here over the past few weeks. I feel like I'm taking advantage of you, but I'm not sure where else to turn! Hopefully I'll start to get this all figured out, soon.

Until then, however, another question...

I'm working with two (2) Random Date formulas. One is setting an opening date, and the second is setting a random closing date. The opening date formula is working perfectly fine. However, the closing date doesn't seem to be using the opening date as the parameter, like I am intending. I'm sure I've just got the formula screwed up. Here are the parameters:

A1 - Number of project dates
D1 - Year of Project(s)
F2 - Quarter Project is supposed to be implemented.

All of the Close dates have to meet three parameters:
Cannot be before the Open date.
Cannot be before 15 March of the same year.
Cannot be after 15 October of the same year.

These are the MOST BASIC parameters. Eventually (or now, if the formula/code is simple enough) I will need it to be a random date anywhere from seven to 180 days after the open date. The problem is, once it starts to move out, it will still have to follow the same basic parameters as listed above, just under the next year... Meaning, If it Open on, say 31 October of 2025, it cannot Close on 02 February 2026. It will have to wait until at least 15 March 2026 to Close.

The CF is just there to highlight the discrepancies I'm looking to fix.

Here is, basically, what I'm working with:

Book3
ABCDEFGHIJKLMN
11120252
2
34/8/20256/25/2025
44/16/20255/26/2025
54/21/20254/30/2025
64/22/20254/18/2025
75/5/20254/19/2025
85/20/20255/11/2025
95/25/20256/18/2025
106/10/20259/2/2025
116/15/20259/26/2025
126/22/20256/27/2025
136/30/20257/4/2025
14
Sheet1
Cell Formulas
RangeFormula
E3:E13E3=IFS($N$1=1,SORT(RANDARRAY($A$1,1,DATE(K1,1,1),DATE(K1,3,31),TRUE)), $N$1=2,SORT(RANDARRAY($A$1,1,DATE(K1,4,1),DATE(K1,6,30),TRUE)), $N$1=3,SORT(RANDARRAY($A$1,1,DATE(K1,7,1),DATE(K1,9,30),TRUE)), $N$1=4,SORT(RANDARRAY($A$1,1,DATE(K1,10,1),DATE(K1,12,31),TRUE)))
M3:M13M3=IFS($N$1=1,(RANDARRAY($A$1,1,(E3),DATE($K$1,6,15),TRUE)), $N$1=2,(RANDARRAY($A$1,1,(E3),DATE($K$1,10,15),TRUE)), $N$1=3,(RANDARRAY($A$1,1,(E3),DATE($K$1,10,15),TRUE)), $N$1=4,(RANDARRAY($A$1,1,(E3),DATE($K$1,10,15),TRUE)))
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
M:MExpression=M3<E3textNO
 
How about:

Book1
ABCDEFGHIJKLMN
11120252
2
34/16/20258/19/2025
44/24/20256/17/2025
55/5/20259/3/2025
65/8/20259/6/2025
75/11/20258/17/2025
85/12/20258/21/2025
96/21/20259/26/2025
106/22/202510/15/2025
116/23/20259/4/2025
126/24/20259/15/2025
136/26/202510/10/2025
14
Sheet1
Cell Formulas
RangeFormula
E3:E13E3=IFS($N$1=1,SORT(RANDARRAY($A$1,1,DATE(K1,1,1),DATE(K1,3,31),TRUE)), $N$1=2,SORT(RANDARRAY($A$1,1,DATE(K1,4,1),DATE(K1,6,30),TRUE)), $N$1=3,SORT(RANDARRAY($A$1,1,DATE(K1,7,1),DATE(K1,9,30),TRUE)), $N$1=4,SORT(RANDARRAY($A$1,1,DATE(K1,10,1),DATE(K1,12,31),TRUE)))
M3:M13M3=BYROW(E3#,LAMBDA(s,LET(y,YEAR(s)+OR(AND(MONTH(s)=10,DAY(s)>15),MONTH(s)>10),RANDBETWEEN(MAX(s+7,DATE(y,3,15)),DATE(y,10,15)))))
Dynamic array formulas.
 
Upvote 0
How about:
Not sure what's different with yours and mine... I copied both from the formula bar at the bottom, and by clicking on the E3/M3, and each time, I get the same result:

Book3
ABCDEFGHIJKLMN
11120252
2
34/21/2025#NAME?
45/1/2025
55/1/2025
65/8/2025
75/10/2025
86/2/2025
96/10/2025
106/10/2025
116/20/2025
126/23/2025
136/30/2025
14
Sheet1
Cell Formulas
RangeFormula
E3:E13E3=IFS($N$1=1,SORT(RANDARRAY($A$1,1,DATE(K1,1,1),DATE(K1,3,31),TRUE)), $N$1=2,SORT(RANDARRAY($A$1,1,DATE(K1,4,1),DATE(K1,6,30),TRUE)), $N$1=3,SORT(RANDARRAY($A$1,1,DATE(K1,7,1),DATE(K1,9,30),TRUE)), $N$1=4,SORT(RANDARRAY($A$1,1,DATE(K1,10,1),DATE(K1,12,31),TRUE)))
M3M3=BYROW(E3#,LAMBDA(s,LET(y,YEAR(s)+OR(AND(MONTH(s)=10,DAY(s)>15),MONTH(s)>10),RANDBETWEEN(MAX(s+7,DATE(y,3,15)),DATE(y,10,15)))))
Dynamic array formulas.
 
Upvote 0
Not sure what's different with yours and mine...
Your Excel versions - your version does not have the BYROW function.
I have not checked all the details of what the formula is supposed to be doing but what happens if you amend Eric's formula in M3 to this?
Excel Formula:
=LET(s,E3#,LET(y,YEAR(s)+OR(AND(MONTH(s)=10,DAY(s)>15),MONTH(s)>10),RANDBETWEEN(MAX(s+7,DATE(y,3,15)),DATE(y,10,15))))
 
Upvote 0
My apologies! Peter has the right of it, Excel 2021 does not have BYROW. Sadly, Peter's version doesn't work right either, I tested it on a copy of 2021 I have on a laptop. The MAX works on the whole range, not just the row in question. You can try this version, but it requires that you drag down the formula:

Book1
ABCDEFGHIJKLMN
11120252
2
34/22/20258/19/2025
44/25/202510/1/2025
54/30/20257/6/2025
65/7/20255/25/2025
75/12/20256/17/2025
86/4/20259/17/2025
96/8/20259/17/2025
106/10/20257/13/2025
116/10/20259/9/2025
126/15/20258/20/2025
1311/12/20254/27/2026
14
Sheet1
Cell Formulas
RangeFormula
M3:M13M3=LET(s,E3,LET(y,YEAR(s)+OR(AND(MONTH(s)=10,DAY(s)>15),MONTH(s)>10),RANDBETWEEN(MAX(s+7,DATE(y,3,15)),DATE(y,10,15))))
 
Upvote 0
My apologies! Peter has the right of it, Excel 2021 does not have BYROW. Sadly, Peter's version doesn't work right either, I tested it on a copy of 2021 I have on a laptop. The MAX works on the whole range, not just the row in question. You can try this version, but it requires that you drag down the formula:
Oooof course it doesn't...! Seems like I'm always one step behind on things. I appreciate your help, but unfortunately, dragging-down isn't going to work, as this will have to be a Ph,D (Push here, Dummy) worksheet, with everything locked so that no one can screw things up without a little effort.

I've already had to re-install Excel on my primary computer once in the last seven days. I'm really hoping not to have to upgrade, now! I can't use the 365 versions, as my primary computer cannot be "connected" to any service-type systems. It's a company rule...
 
Upvote 0
Give this a try:

Book1
ABCDEFGHIJKLMN
11120254
2
310/24/20254/15/2026
410/26/20254/22/2026
511/2/20256/20/2026
611/10/20257/16/2026
711/22/20257/19/2026
811/23/20257/26/2026
911/23/20258/24/2026
1012/17/20258/7/2026
1112/20/20253/17/2026
1212/22/20255/20/2026
1312/29/20257/3/2026
14
Sheet1
Cell Formulas
RangeFormula
E3:E13E3=IFS($N$1=1,SORT(RANDARRAY($A$1,1,DATE(K1,1,1),DATE(K1,3,31),TRUE)), $N$1=2,SORT(RANDARRAY($A$1,1,DATE(K1,4,1),DATE(K1,6,30),TRUE)), $N$1=3,SORT(RANDARRAY($A$1,1,DATE(K1,7,1),DATE(K1,9,30),TRUE)), $N$1=4,SORT(RANDARRAY($A$1,1,DATE(K1,10,1),DATE(K1,12,31),TRUE)))
M3:M13M3=LET(s,E3#,minproj,7,LET(y,YEAR(s)+(s>DATE(YEAR(s),10,15-minproj)),RANDBETWEEN(IF(s+minproj>DATE(y,3,15),s+minproj,DATE(y,3,15)),DATE(y,10,15))))
Dynamic array formulas.


The minproj variable in the formula is the minimum number of days you want from the start of the project to the earliest end date possible.
 
Upvote 0
Give this a try:



The minproj variable in the formula is the minimum number of days you want from the start of the project to the earliest end date possible.
This is working really well. However, I'm running into an issue where it's actually moving things out TOO far! Is there any way we (like how I'm acting like I'm ANY part of the process other than making demands?!?) can make it so if the close date will fall past the current date ["TODAY()" I guess...?], the space is left blank?

(I'm sorry if this seems a little bit like it's missing the point. I'm also using this to go back to Q4 of last year because some of these projects are overlapping. In most cases, those projects already have Close dates assigned.)
 
Upvote 0
Well, this is what that would look like:

Book1
ABCDEFGHIJKLMN
11120254
2
310/11/2025 
410/15/2025
510/30/2025
611/1/2025
711/9/2025
811/11/2025
911/18/2025
1011/19/2025
1111/20/2025
1211/27/2025
1312/4/2025
14
Sheet6
Cell Formulas
RangeFormula
E3:E13E3=IFS($N$1=1,SORT(RANDARRAY($A$1,1,DATE(K1,1,1),DATE(K1,3,31),TRUE)), $N$1=2,SORT(RANDARRAY($A$1,1,DATE(K1,4,1),DATE(K1,6,30),TRUE)), $N$1=3,SORT(RANDARRAY($A$1,1,DATE(K1,7,1),DATE(K1,9,30),TRUE)), $N$1=4,SORT(RANDARRAY($A$1,1,DATE(K1,10,1),DATE(K1,12,31),TRUE)))
M3:M13M3=LET(s,E3#,minproj,7,y,YEAR(s)+(s>DATE(YEAR(s),10,15-minproj)),d,RANDBETWEEN(IF(s+minproj>DATE(y,3,15),s+minproj,DATE(y,3,15)),DATE(y,10,15)),IF(d<TODAY(),d,""))
Dynamic array formulas.


The dates for the fourth quarter, after 10/15, are trying to pick a range between 3/15 and 10/15 of the next year. Since today is 3/12, they all will be past the current date, so they all are blank. Is there some other condition you can use to decide how far out you want to go?
 
Upvote 0

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