+ Reply to Thread
Results 1 to 5 of 5

problem with getting a random output from range of cells when a criteria is meet

  1. #1
    Registered User
    Join Date
    06-11-2018
    Location
    New Zealand
    MS-Off Ver
    2103
    Posts
    4

    problem with getting a random output from range of cells when a criteria is meet

    Hi

    i am wanting to write a formula for school reports. I want to input a result into column 1, which will then depending on the result, choose a random comment from a range of cells in column B
    and display that in column C


    So "5a", entered into Column A, chooses a comment from say Cell 1 -8 of column B
    If "5p" would choose a random comment from Cell 9-16 of column B

    any help would be greatly appreciated

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,899

    Re: problem with getting a random output from range of cells when a criteria is meet

    Try this:

    =INDEX($B:$B,IF(A1="5a",RANDBETWEEN(1,8),IF(A1="5p",RANDBETWEEN(9,16),"")))

  3. #3
    Registered User
    Join Date
    06-11-2018
    Location
    New Zealand
    MS-Off Ver
    2103
    Posts
    4

    Re: problem with getting a random output from range of cells when a criteria is meet

    Awesome thank you so much

    Is there anyway to alter the formula so that once a random value is assigned to a cell it does not change every time i add another grade? So if "5a" is selected in A1 the value in C1 does not change when I enter a value for A2?

  4. #4
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,899

    Re: problem with getting a random output from range of cells when a criteria is meet

    You can use VBA solution or copy and paste value

  5. #5
    Registered User
    Join Date
    06-11-2018
    Location
    New Zealand
    MS-Off Ver
    2103
    Posts
    4

    Re: problem with getting a random output from range of cells when a criteria is meet

    This is the formula I am using to generate a random comment from a range of cells. Is there anything I could add to stop it from changing the comments every time I enter a new students score?

    =INDEX($I:$I,IF(D17="a",RANDBETWEEN(2,4),IF(D17="b",RANDBETWEEN(5,7),IF(D17="c",RANDBETWEEN(9,11),IF(D17="D",RANDBETWEEN(14,17),"""")))))

+ 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. Replies: 9
    Last Post: 11-28-2017, 09:34 AM
  2. [SOLVED] Macro to clear cells in range & move up if certain cells meet criteria
    By samder68 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-09-2016, 10:52 PM
  3. [SOLVED] COUNTIF on range of cells that meet 2 criteria
    By mattsafact in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-06-2016, 10:54 AM
  4. [SOLVED] Help with loop to select range of cells that meet criteria
    By NU2vba in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2016, 02:27 AM
  5. Duplicate problem when listing cells that meet criteria
    By merrick07 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-18-2013, 04:25 PM
  6. Paste range of cells that meet criteria
    By lorena.tgarza in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-04-2012, 09:51 PM
  7. sum a range of cells that meet one criteria
    By shanevo6 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-10-2007, 04:06 PM

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