Spreadsheet for random names in a set period of time (for drug testing).

jchebert1979

New Member
Joined
Jan 15, 2020
Messages
11
Office Version
  1. 2016
Platform
  1. MacOS
Hello everyone, this is my first post after watching a couple videos on Mr. Excel's blog. I only have a minimal amount of knowledge with excel's formulas, and I am a helping a small doctor's office that just implemented drug testing. Right now the doctor is doing it every month and agrees that it is overkill for both her and the patients, but also if the patient knows they will be tested every month, they can potentially beat it. I've looked into paid programs that can do what they need, but they are just too expensive for the clinic.

I came across a Mr Excel blog post from 2015 in which the sheet gives you random names using if(is) and (rand) along with VLookup for the names, however it does not account for a set period of time. There are also a few other videos on YouTube that use different formulas, but the result is very similar. I need a formula that will give names to test every patient randomly, two times in a six month period. Can this even be done and if so can anyone help me?

Thanks, Jason
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
see if you can develop something from this

Patients are in A3 to A32, their previously test dates in B3 to F32 (created randomly for testing)
Col G to work out number of tests within last 6 months prior.
Col H to create a random number for each patient
Cell A1 to pick random patient but excl those has 2 or more tests within last 6 months (<=2 in Col G)

Press F9 to recalculate thus pick another patient

Book1
ABCDEFGH
1Patient 5
2Test date
3Patient 116/01/201926/01/201925/04/201900.26070383
4Patient 231/10/201904/07/201929/05/201910.832238414
5Patient 314/02/201917/02/201915/03/201900.91730194
6Patient 405/03/201916/03/201901/08/201910.726770643
7Patient 504/02/201906/02/201915/07/201900.07249397
8Patient 623/03/201926/11/201930/03/201910.082798858
9Patient 720/12/201930/10/201912/10/201930.114130873
10Patient 801/11/201903/11/201922/12/201930.220755477
11Patient 904/02/201926/01/201910/07/201900.43424456
12Patient 1007/01/202017/09/201925/11/201930.496984819
13Patient 1122/01/201905/04/201908/06/201900.916884105
14Patient 1208/10/201913/06/201922/01/201910.132690021
15Patient 1324/05/201925/01/201925/12/201910.640062885
16Patient 1413/07/201926/03/201904/08/201910.273768115
17Patient 1503/08/201906/06/201912/12/201920.034328888
18Patient 1616/07/201918/08/201907/12/201920.371134669
19Patient 1715/06/201929/12/201929/03/201910.353927845
20Patient 1827/07/201921/04/201909/02/201910.425306048
21Patient 1905/01/202003/04/201927/12/201920.881991127
22Patient 2019/04/201926/04/201930/11/201910.574746728
23Patient 2118/02/201908/06/201905/01/202010.202832651
24Patient 2206/10/201908/03/201930/04/201910.313755041
25Patient 2303/09/201905/02/201918/12/201920.899181462
26Patient 2412/02/201918/06/201931/07/201910.849615504
27Patient 2507/03/201902/07/201910/11/201910.533057934
28Patient 2625/02/201905/12/201918/01/201910.955715317
29Patient 2715/08/201907/11/201926/09/201930.442405024
30Patient 2801/09/201919/08/201912/07/201920.772979177
31Patient 2914/01/202010/09/201918/08/201930.347549786
32Patient 3015/05/201904/10/201921/12/201920.977656146
Sheet5
Cell Formulas
RangeFormula
A1A1=INDEX(A3:A32,MATCH(MINIFS(H3:H32,G3:G32,"<"&2),H3:H32,0))
B3:D32B3=TODAY()-RANDBETWEEN(1,365)
G3:G32G3=COUNTIF(B3:F3,">"&DATE(YEAR(TODAY()),MONTH(TODAY())-6,DAY(TODAY())))
H3:H32H3=RAND()


click this symbol to copy the spreadsheet

Untitled.jpg
 
Upvote 0
Wow, thank you so much, Alan. I'm sorry for the late response. I had some health problems, ended up in the hospital, and was feeling too bad to even look at the computer. Again, I appreciate it. I will let you know how it goes when I start to test it out.
 
Upvote 0
The only problem I'm having is cell A1 is not generating a patient name. I tried a few different things, but I just ended up messing thing up.
 
Upvote 0
sorry to hear about you're not being well, hope you're better now.

have you tried the below method to copy the excel file for testing?

Untitled.jpg
 
Upvote 0
Yes, that's what I used. I've gone through the formulas as well and compared them to the formula sheet, they all look correct. I just tried setting hard dates instead of randomly generated ones. Now I'm trying to learn what the formulas mean and do.
 
Upvote 0
ok, so what is it showing on A1?
 
Upvote 0
could you post the file that's not working like I did in post#2 using

 
Upvote 0
right, your excel version doesn't has the MINIF() function, try this instead

Book1
ABCDEFGHI
1Patient 23
2Test date
3Patient 105/04/201924/09/201901/06/201910.705166266
4Patient 224/08/201903/04/201927/04/201910.114845709
5Patient 316/08/201913/08/201917/01/202030.358795684
6Patient 417/10/201926/11/201925/01/201920.835985197
7Patient 502/01/202017/09/201907/11/201930.370956742
8Patient 631/01/201925/02/201920/05/201900.230235661
9Patient 712/01/202016/12/201903/06/201920.738026772
10Patient 802/08/201917/06/201927/01/201910.742011846
11Patient 916/04/201907/09/201914/03/201910.392700375
12Patient 1028/10/201904/08/201902/04/201920.342311803
13Patient 1130/05/201910/01/202019/09/201920.263064444
14Patient 1205/02/201906/03/201902/04/201900.357876161
15Patient 1313/10/201920/08/201922/11/201930.738432299
16Patient 1420/08/201920/02/201929/06/201910.385405905
17Patient 1519/09/201927/11/201930/11/201930.01071849
18Patient 1616/08/201905/05/201914/02/201910.949761439
19Patient 1701/08/201919/03/201927/06/201910.370048489
20Patient 1807/10/201905/12/201901/03/201920.105753096
21Patient 1920/12/201919/10/201905/10/201930.065534724
22Patient 2005/10/201916/11/201915/08/201930.228139342
23Patient 2114/05/201911/03/201927/03/201900.85646768
24Patient 2207/12/201912/07/201927/04/201910.807335585
25Patient 2328/03/201925/06/201923/08/201910.094144026
26Patient 2426/01/201914/11/201927/05/201910.828634287
27Patient 2510/08/201918/11/201901/10/201930.452773207
28Patient 2619/04/201926/10/201910/10/201920.874112405
29Patient 2726/03/201913/01/202024/05/201910.638615103
30Patient 2817/12/201909/07/201930/10/201920.935714096
31Patient 2907/10/201913/05/201922/01/201910.197396617
32Patient 3007/03/201927/06/201902/07/201900.818142974
33
Sheet4
Cell Formulas
RangeFormula
A1A1{=INDEX(A3:A32,MATCH(MIN(IF(G3:G32<2,H3:H32)),H3:H32,0))}
B3:D32B3=TODAY()-RANDBETWEEN(1,365)
G3:G32G3=COUNTIF(B3:F3,">"&DATE(YEAR(TODAY()),MONTH(TODAY())-6,DAY(TODAY())))
H3:H32H3=RAND()
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,557
Members
449,088
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