Closed Thread
Results 1 to 11 of 11

How to Skip Blank cells while using "Randbetween" function

  1. #1
    Registered User
    Join Date
    03-08-2016
    Location
    Amman, Jordan
    MS-Off Ver
    2013
    Posts
    32

    Exclamation How to Skip Blank cells while using "Randbetween" function

    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

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How to Skip Blank cells while using "Randbetween" function

    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).
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Registered User
    Join Date
    03-08-2016
    Location
    Amman, Jordan
    MS-Off Ver
    2013
    Posts
    32

    Re: How to Skip Blank cells while using "Randbetween" function

    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

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How to Skip Blank cells while using "Randbetween" function

    I tested on my own workbook and received no such result. I can only suggest you upload an actual workbook.

    Regards

  5. #5
    Registered User
    Join Date
    03-08-2016
    Location
    Amman, Jordan
    MS-Off Ver
    2013
    Posts
    32

    Re: How to Skip Blank cells while using "Randbetween" function

    Can you check this file
    Attached Files Attached Files

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How to Skip Blank cells while using "Randbetween" function

    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

  7. #7
    Registered User
    Join Date
    03-08-2016
    Location
    Amman, Jordan
    MS-Off Ver
    2013
    Posts
    32

    Re: How to Skip Blank cells while using "Randbetween" function

    Thanks alot, it is working fine

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How to Skip Blank cells while using "Randbetween" function

    You're welcome!

    Regards

  9. #9
    Registered User
    Join Date
    07-14-2018
    Location
    New Hampshire
    MS-Off Ver
    2016
    Posts
    1

    Re: How to Skip Blank cells while using "Randbetween" function

    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.

  10. #10
    Registered User
    Join Date
    04-25-2022
    Location
    Caledon, ON, Canada
    MS-Off Ver
    MS Office 365
    Posts
    13

    Re: How to Skip Blank cells while using "Randbetween" function

    Quote Originally Posted by XOR LX View Post
    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, 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

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,908

    Re: How to Skip Blank cells while using "Randbetween" function

    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Skip Blank cells while using "Randbetween" function
    By Ravana in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-10-2017, 07:58 AM
  2. [SOLVED] Copy cells from range "C3" to "F3" with loop and blank field
    By masterm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-16-2015, 01:03 PM
  3. [SOLVED] IF function returning blank cells as 0 instead of a blank even though "" is being used
    By scootty83 in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 3
    Last Post: 06-02-2015, 02:47 AM
  4. [SOLVED] Keeping particular cell blank if the related cells show "0" or "blank"
    By Anuru in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-24-2014, 05:30 AM
  5. [SOLVED] Replace all BLANK cells in column with header title "Balance" to "0"
    By ks100 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-21-2014, 09:25 AM
  6. Replies: 3
    Last Post: 02-16-2011, 02:55 PM
  7. "Left" function - How to skip over a full stop in text
    By Grimace in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-20-2010, 03:08 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1