+ Reply to Thread
Results 1 to 5 of 5

Selecting random rows based on criteria in other columns

  1. #1
    Registered User
    Join Date
    07-08-2012
    Location
    NA
    MS-Off Ver
    Excel Starter/Sometimes Excel 2010
    Posts
    33

    Selecting random rows based on criteria in other columns

    I would like to select cells from a specific column, and produce the rows.
    So I might want to pick a random ID, but filter/choose by combinations of event type. I can delete rows based on event, but it would be nice to have something that can do it all together. In the data below the event types can occur more than once. I have posted it just to give a visual example.




    HTML Code: 

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Selecting random rows based on criteria in other columns

    I don't follow what you want. Can you be a bit more specific? Also - is it a VBA solution that you definitely want?
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Registered User
    Join Date
    07-08-2012
    Location
    NA
    MS-Off Ver
    Excel Starter/Sometimes Excel 2010
    Posts
    33

    Re: Selecting random rows based on criteria in other columns

    No, I just thought that VBA would be the best solution.

    I want a formula that will randomly pick a row. However, sometimes I might want to subset my data.

    So it might look like: if event 1 = DY85, then pick a random row with this constraint. So the output might be:
    Name ID Event1 Event2 Value Value2
    J 40 DY85 OZPV 0.599 -7

    Or I might want to subset by adding constraints based on event1 and event2.
    Does this help?

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Selecting random rows based on criteria in other columns

    Yea, you probably need at least some VBA. The formulas sued here count the number of rows that contain the search term (J1) - let's call it n. RANDBETWEEN then randomly selects an integer between 1 and n and returns the corresponding mtching row.

    However...


    Every time it recalculates (data re-entry, hit F9, etc) a new random number is generated and a new result appears. Someone out there should be able to add on a bit of VBA to give you a one-off (non-updating) randomly selected number in O1. In which case, problem solved??
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    07-08-2012
    Location
    NA
    MS-Off Ver
    Excel Starter/Sometimes Excel 2010
    Posts
    33

    Re: Selecting random rows based on criteria in other columns

    Thank you!

+ 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] Selecting rows from one tab based on date test criteria
    By Rauls in forum Excel General
    Replies: 6
    Last Post: 11-08-2014, 03:00 PM
  2. Dynamic Arrays - Selecting some rows based on criteria
    By AHFoddeR in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-23-2013, 03:55 AM
  3. [SOLVED] Finding Values in a Column based on Criteria and Selecting Rows Above
    By LvaughnL in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-04-2013, 03:07 PM
  4. [SOLVED] Selecting rows based on criteria
    By JCP in forum Excel General
    Replies: 3
    Last Post: 04-05-2006, 04:30 AM
  5. Selecting rows based simultaneously on 3 criteria
    By miserere in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-21-2005, 03:05 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