RANDOMDATE

RANDOMDATE(start_year, end_year, [num_dates])
start_year
the lower limit of the range of years for the random date.
end_year
the upper limit of the range of years for the random date.
[num_dates]
the number of dates to be returned.

RANDOMDATE will return a number of random dates given a range of years.

lrobbo314

Well-known Member
Joined
Jul 14, 2008
Messages
3,927
Office Version
  1. 365
Platform
  1. Windows
RANDOMDATE will return a number of random dates given a range of years.

If you omit the optional third argument, the function will return a single random date.

Inspired by a recent video by @MrExcel, video link.

Excel Formula:
  RANDOMDATE
  =LAMBDA(
    year_start,year_end,[num_dates],
        LET(
            s,SEQUENCE(num_dates),
                MAP(s,LAMBDA(x,DATE(RANDBETWEEN(year_start,year_end),1,RANDBETWEEN(1,365))))
        )
)

RANDOMDATE
ABCDE
1With all arguments enteredWithout optional argument
22/28/20136/19/2019
36/24/2009
46/20/2022
58/25/2022
61/12/2015
712/27/2020
85/4/2019
99/7/2017
102/5/2022
1112/26/2011
Sheet2
Cell Formulas
RangeFormula
A2:A11A2=RANDOMDATE(2008,2022,10)
E2E2=RANDOMDATE(2008,2022,)
Dynamic array formulas.


I tried to adapt a VBA function to a LAMBDA function, but kept getting a "Nested Arrays" error whenever I tried to incorporate the MAP function in order to be able to return multiple dates.

Here is the function I was trying to use.

Excel Formula:
=LAMBDA(
    year_start,year_end,
        LET(
            m,RANDBETWEEN(1,12),
            y,RANDBETWEEN(year_start,year_end),
            d,
                IF(OR(m={1,3,5,7,8,10,12}),31,
                IF(OR(m={4,6,9,11}),30,
                    IF(MOD(y,4)=0,
                        29,
                        28
                    )
                )
                ),
                DATE(y,m,d)
        )
)

I would be interested to know if anyone would be able to tell me how you could make that one work.

But, @MrExcel's version was more elegant anyway.
 
Upvote 0
Another version using the "counting days" logic from the start and MAKEARRAY function:

Excel Formula:
=LAMBDA(start_year,end_year,[how_many],
    LET(
        how_many, IF(how_many <=0, 1, how_many),
        total_days,DATE(end_year,12,31) - DATE(start_year,1,1),
        MAKEARRAY(how_many, 1,
            LAMBDA(r,c,
                LET(random_days,RANDBETWEEN(0,total_days),
                    result,TEXT(DATE(start_year,1,random_days), "mm/dd/yyyy"),
                    result
                )
          )
      ))
)
Book10
ABCD
1Start Year2005Random Days
2End Year200605/14/2006
3How Many1001/10/2005
409/03/2006
512/26/2006
608/31/2005
712/27/2005
805/22/2006
904/01/2006
1010/27/2006
1110/11/2005
Sheet1
Cell Formulas
RangeFormula
D2:D11D2=LAMBDA(start_year,end_year,[how_many], LET( how_many, IF(how_many <=0, 1, how_many), total_days,DATE(end_year,12,31)-DATE(start_year,1,1), MAKEARRAY(how_many, 1, LAMBDA(r,c, LET(random_days,RANDBETWEEN(0,total_days), result,TEXT(DATE(start_year,1,random_days), "mm/dd/yyyy"), result ) ) )) )(B1,B2,B3)
Dynamic array formulas.
 
Last edited:
Great challenge, great functions both!!
My take:
RANDATE(ya,[yb],[r],[c],[fm])
ya: year 1
[yb]: year 2, if omitted => year 1 (no error is returned if ya>yb)
[r]: nr. rows to spill
[c]: nr. clms to spill
- if [r] omitted => r=1, functions spills row vector of "c" values
- if [c] omitted => c=1, function spills clm vector of "r" values
- if both omitted => 1 value only
- if none omitted => function spills 2D array "r" rows x "c" columns
[fm]: format argument, if omitted, no format, if not omitted => TEXT(values,fm)
Excel Formula:
=LAMBDA(ya, [yb], [r], [c], [fm],
    LET(
        y, IF(yb, yb, ya),
        x, RANDARRAY(IF(r, r, 1), IF(c, c, 1), "1-1-" & MIN(ya, y), "31-12-" & MAX(ya, y), 1),
        IF(fm = "", x, TEXT(x, fm))
    )
)
Book1
ABCDEFGHIJKL
1
2no arguments omittedsingle datenumeric dates, fm, omitted
3=RANDATE(2022,2020,5,3,"ddd dd mmm-yyy")=RANDATE(2022,,,,"ddd mmm-yyy")=RANDATE(2000,2022,27)
4Fri 07 Jan-2022Sun 29 May-2022Tue 18 May-2021Sun Aug-202237769
5Wed 02 Feb-2022Wed 12 May-2021Thu 17 Sep-202041148
6Tue 25 Aug-2020Wed 14 Dec-2022Fri 17 Dec-2021=RANDATE(2022)42224
7Wed 28 Sep-2022Sat 22 Aug-2020Mon 03 Aug-20204468940585
8Sat 09 Oct-2021Tue 23 Aug-2022Sat 30 Apr-202238795
943234
10row spill, r,omitted37553
11=RANDATE(2022,2018,,7,"yyy-mmm dd (ddd)")40229
122022-Jul 07 (Thu)2021-Apr 12 (Mon)2019-Jul 26 (Fri)2018-Oct 23 (Tue)2018-Aug 11 (Sat)2022-Mar 18 (Fri)2019-Jun 09 (Sun)43886
1339519
14clm spill, c, omittedall dates same year, yb, omitted39295
15=RANDATE(2022,2015,15,,"mm/dd/yyy ddd")=RANDATE(2022,,15,5,"ddd dd/mmm yy")44287
1608/16/2016 TueFri 11/Feb 22Sat 29/Jan 22Fri 14/Oct 22Thu 17/Feb 22Thu 24/Mar 2238208
1712/06/2015 SunFri 13/May 22Wed 14/Sep 22Mon 10/Jan 22Thu 27/Oct 22Fri 25/Nov 2238227
1808/17/2020 MonTue 09/Aug 22Sat 20/Aug 22Mon 22/Aug 22Sat 30/Jul 22Mon 16/May 2236681
1903/17/2016 ThuSun 27/Nov 22Wed 23/Mar 22Sun 27/Feb 22Sat 05/Mar 22Wed 14/Sep 2241502
2008/09/2020 SunWed 11/May 22Mon 20/Jun 22Thu 01/Sep 22Tue 26/Jul 22Wed 25/May 2239945
2105/21/2020 ThuFri 25/Mar 22Tue 08/Nov 22Thu 08/Dec 22Sat 15/Jan 22Fri 06/May 2242286
2208/07/2018 TueSun 24/Apr 22Mon 04/Jul 22Sun 29/May 22Tue 25/Jan 22Fri 16/Dec 2238259
2301/15/2022 SatMon 21/Nov 22Tue 01/Nov 22Mon 21/Nov 22Sun 13/Mar 22Wed 11/May 2236766
2407/06/2016 WedTue 04/Jan 22Fri 16/Sep 22Fri 28/Oct 22Sat 01/Jan 22Sat 01/Jan 2240011
2505/28/2022 SatSat 11/Jun 22Sat 12/Mar 22Mon 12/Sep 22Sat 29/Jan 22Wed 09/Mar 2244847
2606/17/2020 WedThu 03/Mar 22Sat 22/Oct 22Thu 22/Sep 22Wed 24/Aug 22Sat 16/Apr 2237291
2703/25/2019 MonSun 16/Oct 22Sat 22/Oct 22Sun 29/May 22Thu 11/Aug 22Wed 23/Nov 2238901
2806/05/2018 TueMon 30/May 22Tue 31/May 22Thu 03/Nov 22Tue 03/May 22Mon 25/Jul 2236656
2909/02/2016 FriSun 26/Jun 22Sat 05/Mar 22Wed 11/May 22Tue 23/Aug 22Thu 04/Aug 2239354
3007/24/2016 SunThu 17/Feb 22Mon 21/Feb 22Thu 24/Mar 22Fri 04/Nov 22Fri 22/Apr 2244305
31
32
Sheet2
Cell Formulas
RangeFormula
B3,D15,B11,F6,J3,F3B3=FORMULATEXT(B4)
B4:D8B4=RANDATE(2022,2020,5,3,"ddd dd mmm-yyy")
F4F4=RANDATE(2022,,,,"ddd mmm-yyy")
J4:J30J4=RANDATE(2000,2022,27)
F7F7=RANDATE(2022)
B12:H12B12=RANDATE(2022,2018,,7,"yyy-mmm dd (ddd)")
A15A15=FORMULATEXT(B16)
B16:B30B16=RANDATE(2022,2015,15,,"mm/dd/yyy ddd")
D16:H30D16=RANDATE(2022,,15,5,"ddd dd/mmm yy")
Dynamic array formulas.
 
I knew that I could use RANDARRAY instead of using an additional array function!!!

Nice one, @Xlambda! Thanks.

It is wonderful to see different usages of various array functions. That's why I love the Lambda forum.
 
What if we need distributions of dates that need to have no duplicates (all dates delivered should be unique)?
UNQRANDATE(ya,[yb],[r],[c],[fm],[k]) recursive function, calls RANDATE.
-same arguments like RANDATE , plus a randarray size incrementor argument [k]
[k]: always omitted, with every iteration k(i+1)=k(i)*5 , k(0)=r*c ; until rows(unique(values))=r*c
Excel Formula:
=LAMBDA(ya, [yb], [r], [c], [fm], [k],
    LET(
        w, MAX(1, r),
        l, MAX(1, c),
        n, w * l,
        i, IF(k, k, n),
        a, RANDATE(ya, yb, i, , fm),
        u, UNIQUE(a),
        o, ROWS(u),
        IF(o >= n, INDEX(u, SEQUENCE(w, l)), UNQRANDATE(ya, yb, w, l, fm, i * 5))
    )
)
Book1
ABCDEFGHIJKLMNO
1Task: Random array distribution of dates, year 2022 , 36 rows x 10 columns, no duplicates
2
3=UNQRANDATE(2022,,36,10,"dd-mm")
402-0614-0121-0920-0120-0512-1205-0729-1128-0621-12check unique
512-1129-1016-0731-1218-0222-0230-0915-0830-0613-03=ROWS(UNIQUE(TOCOL(B4#)))
607-0310-0806-0822-0608-0727-1226-0810-0919-0903-09360
729-0607-0224-0908-0820-0925-1119-0529-0107-0114-07
808-0602-0326-0415-0213-0930-0423-0111-1004-1215-12=ROWS(B4#)*COLUMNS(B4#)
910-0525-0906-0403-1208-1026-0918-0514-0201-0207-10360
1013-0506-0105-0125-1226-0327-0314-0314-1102-0128-03
1113-0606-0205-0214-1023-1116-0504-0801-1011-0411-07
1202-0411-0618-0124-0501-0720-0301-0531-0808-0218-10
1318-0711-0323-0418-1124-0108-0104-0916-1206-0607-07
1420-0721-0328-0907-1109-1106-1225-1021-0820-0625-02
1530-0505-0923-0212-0129-0815-1119-0105-1205-0604-06
1603-0223-1227-0517-0407-0415-1005-0524-0805-1118-03
1724-1018-0819-0604-0319-0231-0509-0914-0519-1027-08
1806-0526-1002-0912-0610-0120-0226-0719-1224-0711-01
1922-1010-1016-0322-0929-0915-0409-0323-1028-0721-02
2001-0924-1105-0808-1102-1111-0230-0104-0717-0227-10
2112-0417-0923-0926-0217-0302-1024-0402-0522-0103-01
2230-1022-0806-0310-0409-1206-1007-1211-0810-0709-05
2319-0417-0817-1004-0125-0807-0625-0305-0302-0210-03
2407-0901-0428-0429-0316-0231-0316-0410-0203-0720-11
2521-0615-0525-0115-0123-0330-0812-0309-0720-0810-11
2622-0417-1102-1204-1113-1012-0826-0120-1218-0601-11
2723-0826-0613-0727-1122-0331-1017-0724-1221-0111-12
2809-1025-0619-0728-0229-1220-1018-0928-1028-0812-09
2916-0828-1101-0813-0106-0930-0310-1224-0604-1021-10
3022-0713-0216-1114-0907-0809-0805-1020-0422-1203-05
3104-0219-0309-0209-0629-0415-0319-0802-0808-0325-04
3213-1126-0503-1008-0927-0112-0718-1213-1230-1119-11
3301-1230-1203-0423-0527-0903-0617-0514-1227-0208-05
3428-0531-0104-0511-0904-0416-0909-0408-0411-0506-11
3530-0726-1125-0517-0608-1201-0117-0114-0812-0521-07
3605-0427-0624-0223-0626-1223-0716-1031-0701-0615-06
3716-0628-1227-0401-0321-0515-0914-0621-1106-0727-07
3824-0317-1229-0711-1113-0412-1025-0709-0112-0214-04
3929-0507-0513-0816-0103-1103-0818-0422-0515-0721-04
40
Sheet3
Cell Formulas
RangeFormula
B3,M8,M5B3=FORMULATEXT(B4)
B4:K39B4=UNQRANDATE(2022,,36,10,"dd-mm")
M6M6=ROWS(UNIQUE(TOCOL(B4#)))
M9M9=ROWS(B4#)*COLUMNS(B4#)
Dynamic array formulas.
 
Book1
ABCDEFGHIJKLMN
1If nr. of dates we need (dates with no dups) is greater than total days between the 2 years => impossible => error
2 => nr. of unq dates we need (dates with no dups) should be <= total days btwn the years interval.
3r*c <= (31-Dec-max(ya,yb))-(1-Jan-min(ya,yb))+1
4Example for years interval 2020-2021
52020 (leap year) had 366 days and 2021 had 365 days => max possible days=731
6732 days >731 => error731 days => all unq (no dups)60x4=240 unq dates (no dups)
7=UNQRANDATE(2021,2020,732)=UNQRANDATE(2021,2020,731)=UNQRANDATE(2020,2021,60,4,"dd-mmm-yy")
8#VALUE!4390201-Aug-2011-Oct-2016-Feb-2125-Dec-20
943856check unique10-Feb-2128-Apr-2016-Oct-2030-Nov-20
1044351=ROWS(UNIQUE(E8#))24-Jun-2126-Feb-2108-Sep-2116-Aug-20
114454873118-Dec-2130-Oct-2121-Mar-2128-May-20
124414928-Sep-2106-Jul-2018-Nov-2009-Dec-20
1343945=ROWS(E8#)09-Apr-2009-Apr-2104-Dec-2102-Jun-20
144437973107-Feb-2014-Apr-2030-May-2112-Jun-21
154453823-Mar-2031-Jul-2104-Apr-2124-Nov-20
1643855=ROWS(UNIQUE(TOCOL(J8#)))08-Sep-2018-Mar-2031-Jan-2126-Oct-20
174426024016-Nov-2119-Apr-2008-Jul-2014-Jan-21
184419325-Feb-2007-Jan-2021-Mar-2003-Oct-20
1944389=COUNTA(J8#)01-Jul-2117-Aug-2119-Feb-2118-Sep-21
204412824021-May-2012-Jan-2121-Dec-2023-Jun-21
214444126-Jul-2115-Dec-2125-Sep-2107-Sep-21
224400602-Apr-2122-Nov-2118-Jan-2120-Apr-21
234408224-Apr-2012-Dec-2002-Mar-2102-Aug-20
244436705-Jan-2121-Sep-2112-Jul-2104-Feb-20
254405128-Mar-2010-Dec-2105-Oct-2114-Jul-20
264419722-Oct-2108-Feb-2019-May-2101-Aug-21
274387207-Jul-2003-Mar-2123-Apr-2002-Sep-21
284424329-Nov-2124-Dec-2120-Feb-2128-Dec-21
294424421-Jul-2124-Jul-2103-Jun-2011-Nov-21
304450406-Apr-2006-Jan-2006-Jul-2110-Jul-21
314401305-Apr-2024-Aug-2122-Nov-2026-Apr-20
324384808-Dec-2115-Sep-2018-Dec-2003-Nov-21
334419809-Jul-2112-Jun-2002-Aug-2130-Mar-21
344422314-Oct-2012-Feb-2124-Apr-2107-Jun-20
354424812-Nov-2117-Dec-2122-Apr-2021-Nov-21
364442021-Jun-2128-Nov-2111-Oct-2117-Mar-21
374454027-Nov-2111-Jun-2115-Apr-2116-Nov-20
384398313-Dec-2025-Jan-2027-Feb-2106-Nov-21
394434830-Dec-2111-Nov-2023-Sep-2031-Mar-21
404394002-Jul-2024-Feb-2023-Dec-2128-Jun-21
414389514-Apr-2122-Jun-2102-May-2122-Jun-20
424432417-Jun-2119-Nov-2116-Jun-2125-Jun-20
434385408-Jan-2012-Aug-2105-Nov-2122-May-21
444413205-Feb-2128-Jan-2129-May-2126-Jun-21
454415803-Dec-2130-Aug-2009-Sep-2124-Jul-20
464388628-Mar-2116-May-2129-Jun-2014-Aug-20
474449527-Aug-2031-Dec-2026-May-2023-May-20
484438627-Apr-2005-Jun-2017-Nov-2122-Dec-21
494452917-Oct-2027-Nov-2009-Mar-2025-Oct-20
504427230-Apr-2003-Oct-2103-May-2102-Jan-21
514421203-Feb-2111-Aug-2008-May-2008-Nov-21
524406819-Nov-2014-Sep-2119-Sep-2102-Nov-21
534409213-Jun-2110-Mar-2127-May-2111-Feb-21
544429926-Jul-2015-Nov-2111-Mar-2116-Sep-20
554391410-Sep-2007-Feb-2129-Nov-2018-Apr-21
564432822-Oct-2017-Nov-2020-Nov-2014-Oct-21
574426706-Jun-2120-May-2004-Jul-2126-Aug-20
584430804-Jun-2110-Aug-2114-Jun-2002-Oct-21
594383109-Mar-2115-Jan-2014-Sep-2009-Nov-20
604442309-Oct-2017-Apr-2108-Mar-2126-Dec-21
614418111-Aug-2104-Apr-2010-Apr-2119-Jun-21
624420525-Jul-2015-Feb-2028-Jun-2027-Jun-21
634449901-Nov-2020-Dec-2006-Apr-2103-Jun-21
644453923-Apr-2109-Jun-2013-Mar-2027-Jun-20
654451127-Oct-2029-Oct-2002-Jul-2104-Nov-20
664416125-Mar-2105-Jun-2110-Mar-2016-Aug-21
674455709-Aug-2130-Aug-2105-Mar-2017-Oct-21
6843866
6944061
Sheet6
Cell Formulas
RangeFormula
B7,E7,G19,G16,G13,G10,J7B7=FORMULATEXT(B8)
B8B8=UNQRANDATE(2021,2020,732)
E8:E738E8=UNQRANDATE(2021,2020,731)
J8:M67J8=UNQRANDATE(2020,2021,60,4,"dd-mmm-yy")
G11G11=ROWS(UNIQUE(E8#))
G14G14=ROWS(E8#)
G17G17=ROWS(UNIQUE(TOCOL(J8#)))
G20G20=COUNTA(J8#)
Dynamic array formulas.
 
Book1
ABCDEFGHIJKLMN
1Leap year 2020 has 366 days=> all days can fit a 61x6 array (61*6=366)
2
3=UNQRANDATE(2020,,61,6,"dd-mm")
406-1121-0706-0828-1222-0801-01check unique
523-0726-0829-0824-1202-0512-11=ROWS(UNIQUE(TOCOL(B4#)))
605-1018-0821-0624-0812-0126-04366
729-0105-0607-0814-0706-1216-07
812-1216-0802-0203-0308-0109-01=COUNTA(B4#)
912-0201-1226-0702-0128-1019-05366
1025-0809-1227-1115-1218-0905-05
1125-1111-0414-1225-0602-1113-04CF 29 Feb
1215-0817-0303-0515-1107-1008-04
1311-0519-0627-1201-0901-0204-06
1412-0810-0210-0716-0513-0108-02Obviously, trying to return 367 unique days, for same year
1519-0902-0711-0311-0722-1016-04can never work, function will run out of max iterations limit
1612-0316-0201-0330-0109-0323-01=UNQRANDATE(2020,,367)
1724-0310-0305-1128-0924-0529-06#VALUE!
1820-0202-0911-0205-0703-1126-12
1922-0211-0103-1231-0108-0805-02
2025-0105-0111-0627-0728-0703-01
2122-0704-0706-0602-1015-0924-01
2203-0810-0924-0910-1020-0424-07
2308-0912-0423-1016-1220-0517-07
2427-0219-1208-1102-0804-0429-02
2503-0917-1104-0326-0301-0607-02
2615-0324-0226-1104-0811-1024-06
2730-0327-0129-0425-0909-0907-05
2828-0513-0318-0409-1110-0607-06
2916-0128-0609-1023-0629-0912-09
3014-0830-0627-1018-0729-0703-02
3122-0929-0323-1230-1230-0712-05
3228-0230-0820-0713-0809-0714-03
3318-0217-0415-0106-0903-0426-05
3417-0223-0206-0103-0619-1013-11
3519-0809-0814-0420-0924-1004-12
3616-0910-1214-0525-0307-0321-11
3704-0508-0306-1027-0322-0620-11
3808-0711-1121-1212-1026-0120-10
3919-0315-0725-0708-1220-0816-11
4008-0517-0119-0723-0809-0428-04
4114-0118-1213-0620-0622-0512-06
4219-0118-0307-0115-0609-0218-01
4310-0110-1123-0415-0423-0927-08
4419-0425-0504-0110-0821-0806-05
4517-0522-1203-1006-0721-0110-05
4623-1106-0407-1214-1001-0807-11
4715-1020-0331-1216-0331-0314-06
4818-0622-0117-0904-0904-1131-10
4913-1207-0717-0811-0810-0430-11
5028-0805-1202-0313-1021-0915-02
5103-0704-1020-0128-1107-0405-03
5222-1127-0621-0405-0425-1207-09
5321-0214-0922-0330-0430-0504-02
5405-0823-0318-1129-1228-0108-10
5515-0523-0521-0319-0216-1013-09
5624-0426-1012-0708-0626-0629-11
5722-0421-1027-0925-0431-0529-05
5801-0425-0221-0530-1017-1225-10
5927-0417-1013-0205-0913-0702-04
6024-1101-1009-0618-1009-0530-09
6113-0516-0611-0926-0901-0518-05
6229-1006-0327-0528-0314-0214-11
6320-1201-1119-1131-0811-1217-06
6431-0702-1206-0226-0202-0601-07
65
Sheet4
Cell Formulas
RangeFormula
B3,I16,I8,I5B3=FORMULATEXT(B4)
B4:G64B4=UNQRANDATE(2020,,61,6,"dd-mm")
I6I6=ROWS(UNIQUE(TOCOL(B4#)))
I9I9=COUNTA(B4#)
I17I17=UNQRANDATE(2020,,367)
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B4:G64Expression=B4="29-02"textNO
 
RANDOMDATE will return a number of random dates given a range of years.

If you omit the optional third argument, the function will return a single random date.

Inspired by a recent video by @MrExcel, video link.

Excel Formula:
  RANDOMDATE
  =LAMBDA(
    year_start,year_end,[num_dates],
        LET(
            s,SEQUENCE(num_dates),
                MAP(s,LAMBDA(x,DATE(RANDBETWEEN(year_start,year_end),1,RANDBETWEEN(1,365))))
        )
)
Needed to remove the spaces from before the = before it took.

RANDOMDATE I'm getting a Value error with this one, @Xlambda. I copied it into the name manager as I usually do, but doesn't seem to be correct as written here.
 
RANDOMDATE I'm getting a Value error with this one, @Xlambda. I copied it into the name manager as I usually do, but doesn't seem to be correct as written here.
Function is fine!! I opened a new workbook, copied the function, function works. See the "cell formulas" section beneath mini-sheet? Formulas are identical to the initial post. Double check your data, arguments...
You should post a mini-sheet example, do the same, like I did with this one: (lambda directly in cell, not as function defined name)
Cell Formulas
RangeFormula
F3,F12F3=FORMULATEXT(F4)
B4:D8B4=LAMBDA(ya,[yb],[r],[c],[fm], LET( y, IF(yb, yb, ya), x, RANDARRAY(IF(r, r, 1), IF(c, c, 1), "1-1-" & MIN(ya, y), "31-12-" & MAX(ya, y), 1), IF(fm = "", x, TEXT(x, fm)) ) )(2022,2020,5,3)
F4,F13F4=FORMULATEXT(B4)
B13:B27B13=LAMBDA(ya,[yb],[r],[c],[fm], LET( y, IF(yb, yb, ya), x, RANDARRAY(IF(r, r, 1), IF(c, c, 1), "1-1-" & MIN(ya, y), "31-12-" & MAX(ya, y), 1), IF(fm = "", x, TEXT(x, fm)) ) )(2022,2015,15)
Dynamic array formulas.
 

Forum statistics

Threads
1,214,978
Messages
6,122,545
Members
449,089
Latest member
davidcom

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