+ Reply to Thread
Results 1 to 3 of 3

RandBetween range, skip cell without value in VBA

  1. #1
    Registered User
    Join Date
    02-08-2023
    Location
    Germany
    MS-Off Ver
    365
    Posts
    80

    RandBetween range, skip cell without value in VBA

    I have this function that will go through BG2 and BG17 and randomly display the value of a cell within that range in AS25.
    But, sometimes some of these cells within the range have no value, and it displays nothing in AS25.
    How can I prevent that, by skipping the cells without value?

    Please Login or Register  to view this content.

  2. #2
    Banned User!
    Join Date
    05-13-2023
    Location
    Venera
    MS-Off Ver
    2007
    Posts
    79

    Re: RandBetween range, skip cell without value in VBA

    You should loop while the AS25 is empty (while random value is empty).
    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,968

    Re: RandBetween range, skip cell without value in VBA

    I don't know how many worksheets you are using. You:
    Set ws = Worksheets("Main")

    but, you say:
    Range("BG2:BG17") without qualification so it references the active sheet, whatever that may be (ws=main, or...?)
    Please Login or Register  to view this content.
    Ben Van Johnson

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How to Skip Blank cells while using "Randbetween" function
    By ehabmad in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-25-2022, 10:14 AM
  2. [SOLVED] Randbetween range based on cell values on different sheet
    By psjpsjpsjpsj in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-03-2018, 04:02 AM
  3. [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
  4. [SOLVED] Macro to copy range, skip cell if #n/a
    By sidewaysw in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-11-2016, 05:02 PM
  5. Replies: 10
    Last Post: 07-03-2015, 04:29 PM
  6. [SOLVED] For loop - skip to next cell in range
    By gombi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-27-2014, 04:43 PM
  7. [SOLVED] For each cell in range, but skip vbNullString
    By Jovica in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-05-2014, 09:48 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