I am using two formulas to generate random non-repeating values within a specified range.
1st is =IFERROR(RANDBETWEEN($A$1,$A$2),"")
2nd is =IFERROR(LARGE(ROW(INDIRECT(CONCATENATE("$",$A$1,":$",$A$2)))*NOT(COUNTIF($B$1:B1,ROW(INDIRECT(CONCATENATE("$",$A$1,":$",$A$2))))),RANDBETWEEN(1,($A$2+2-$A$1)-ROW(B1))),"")
These two formulas generate a set of 50 values (depending on until where I drag down the 2nd formula) that are unique with each other.
This works fine with dates too. However, I wanted to include an option to exclude weekends. I already made a VBA userform wherein the user could input the start and end date. But I also wish to include a checkbox to whether or not exclude weekends from the range. If doable, I would wish to extend this to give the user the option to exclude days s/he wishes to exclude.
I found the following formula during my googling:
=DATE(2014, 1, 1)+(LARGE(IF(WEEKDAY((DATE(2014, 1, 1)+ROW($1:$365)-1)*((COUNTIF($A$1:A1, DATE(2014, 1, 1)+ROW($1:$365)-1))=0), 2)<6, ROW($1:$365)-1, ""), RANDBETWEEN(1, SUM(--(WEEKDAY((DATE(2014, 1, 1)+ROW($1:$365)-1)*((COUNTIF($A$1:A1, DATE(2014, 1, 1)+ROW($1:$365)-1))=0), 2)<6)))))
However, I can't make it work for me after a few tweaks and tries. Also, it initiates at a start date of 1/1/2014 plus 365 days (this was relatively simple to correct). My only problem really is trying to exclude weekends from the 50 randomly generated non-repeating dates. Incorporating this to the userform is something I can already.
With this, may I ask for your help. Thanks!