Hi,
I have the below formula in excel, and am facing problem to skip empty cells while random selection
=INDEX(H3:H25,RANDBETWEEN(1,COUNTA(H3:H25)))
Any body can help?
Thanks
Hi,
I have the below formula in excel, and am facing problem to skip empty cells while random selection
=INDEX(H3:H25,RANDBETWEEN(1,COUNTA(H3:H25)))
Any body can help?
Thanks
Hi,
Array formula**:
=INDEX(H:H,INDEX(MODE.MULT(IF(H3:H25<>{"",""},ROW(H3:H25))),RANDBETWEEN(1,SUM(N(LEN(H3:H25)>0)))))
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
Hi,
Thanks for the reply, but when doing the formula, when pressing CTRL & Shift then enter, i get a name from the list, doing F9 again, the cell value is changed to another name randomly, press F9 again, I get either "0" as value or the last name appeared is not changing
any reason why
I tested on my own workbook and received no such result. I can only suggest you upload an actual workbook.
Regards
Can you check this file
Your formula references:
H$3:H$1048576
at the start, in place of my:
H:H
Not sure why you changed it, but this makes all the difference.
Regards
Thanks alot, it is working fine![]()
You're welcome!
Regards
FYI, the formula throws an error if any of the cells contain an error (#DIV/0, #NAME?, #VALUE!, etc.)
Simplest solution is obviously to clean up those errors.
Hi, I just joined after searching for a solution to my problem. I am using MS Office Excel 365. I first started with this formula =INDEX(C4:C18,RANDBETWEEN(1,15)). When I have less than 15 names to choose from I sometimes get a random value of zero. I used the Array above but on occasion the random value generated is zero instead of a name. I have entered the formula as an Array for the range I need. In my current example I have a maximum of 15 cells to randomly select a name but in this case I only have 8 names to randomly select, the rest are blank. The number of names can change from day to day from 4 to 15 names. My blank cells in my Array do contain formulas referencing another tab ie. ='Lookup Data'!H10 if that makes a difference.
This is my Array formula based on the solution provided in a previous post.
{=INDEX(C:C,INDEX(MODE.MULT(IF(C4:C18<>{"",""},ROW(C4:C18))),RANDBETWEEN(1,SUM(N(LEN(C4:C18)>0)))))}
Hopefully I have provided enough information.
Thank you for any help.
Dave
Administrative Note:
Welcome to the forum.
We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.
Please see Forum Rule #4 about hijacking and start a new thread for your query.
If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
Ali
Enthusiastic self-taught user of MS Excel who's always learning!
Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.
NB: as a Moderator, I never accept friendship requests.
Forum Rules (updated August 2023): please read them here.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks