Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

choose a value with criteria

I have this table in cells A1:E5, I would like to randomly select a value out of cells which are non blank.

enter image description here

Please help.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you have Office 365 you could use:
=LET(a,TOCOL(A1:E5,1),INDEX(a,RANDBETWEEN(1,ROWS(a))))

Or =LET(a,UNIQUE(TOCOL(A1:E5,1)),INDEX(a,RANDBETWEEN(1,ROWS(a))))
If you want each number to have the same chance, regardless the times being repeated in the range.

The idea is: TOCOL with ignore blanks argument (1) will filter the range for values only. If you rand between 1 and the number of (unique) values, you can index that array of non-blank values and return the random row’s value within that array.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading