+ Reply to Thread
Results 1 to 24 of 24

Select Random Rows and Display on new sheet

  1. #1
    Forum Contributor
    Join Date
    05-18-2004
    Location
    Portland, Oregon
    MS-Off Ver
    2016
    Posts
    182

    Select Random Rows and Display on new sheet

    Hello Everyone,

    I have been searching and finally found something close to what I would like to do prior to asking you all. In post: http://www.excelforum.com/excel-prog...selection.html they did an excellent job selecting the random rows.

    I need to take it one step further, I need the selected rows to be displayed on a new sheet. The idea being that I have a quiz with hundreds of questions and I only want a random selection to appear when I execute the macro. I plan on hiding the original questions and only displaying the randomly selected ones.

    Thanks for your help in advance!

    Here is the original code from the previous post.

    Please Login or Register  to view this content.
    Last edited by matt4003; 04-01-2009 at 07:10 PM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Select Random Rows and Display on new sheet

    Hi

    Set up and attach an example file showing where your questions will exist, and where you want the output to be placed.

    rylo

  3. #3
    Forum Contributor
    Join Date
    05-18-2004
    Location
    Portland, Oregon
    MS-Off Ver
    2016
    Posts
    182

    Re: Select Random Rows and Display on new sheet

    Hello Rylo! Thank you for your help in advance! I have attached a sample of the worksheet ("quiz") for you to see what I am talking about.

    One note, I did try to edit the code and put "rows" in place of "cells", and tried to preselect the area for the random selection to take place. But I don't think my changes worked.
    Attached Files Attached Files
    Last edited by matt4003; 03-30-2009 at 07:42 PM. Reason: more information.

  4. #4
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Select Random Rows and Display on new sheet

    Hi

    How many questions do you want returned? Is it a fixed number, or will it be asked somehow?


    rylo

  5. #5
    Forum Contributor
    Join Date
    05-18-2004
    Location
    Portland, Oregon
    MS-Off Ver
    2016
    Posts
    182

    Re: Select Random Rows and Display on new sheet

    Hello Rylo,

    It would make the most sense to me to have the number of questions picked be static in the VBA. Hopefully though I will be able to change that value just by changing the single code value.

    Let's start with 5 questions.

    Regards,
    Matt

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Select Random Rows and Display on new sheet

    Here's a start ...
    Last edited by shg; 03-31-2009 at 06:37 PM. Reason: remove attachment
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Contributor
    Join Date
    05-18-2004
    Location
    Portland, Oregon
    MS-Off Ver
    2016
    Posts
    182

    Re: Select Random Rows and Display on new sheet

    Hi Rylo!

    Very cleaver and awesome!

    One thing that I think will be necessary is to understand how the "student" did, or which questions are right and which are wrong. Perhaps I am missing it, but how (on the quiz page) do I show if the answer is right or wrong? Similar to the original example, is it possible to show immediate feedback after the question has been answered?

    Many thanks!
    Matt

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Select Random Rows and Display on new sheet

    Good job, Rylo!

  9. #9
    Forum Contributor
    Join Date
    05-18-2004
    Location
    Portland, Oregon
    MS-Off Ver
    2016
    Posts
    182

    Re: Select Random Rows and Display on new sheet

    Hello Shg,

    Sorry, I didn't even catch that you wrote the file. You and Rylo are a good team:-)

    Any thoughts on the other part of the question? Providing instant feedback to the correctness of the answer?

    Many thanks!

    Matt

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Select Random Rows and Display on new sheet

    Maybe like this.

    My teammate will take over from here ...
    Last edited by shg; 03-31-2009 at 06:36 PM. Reason: remove attachment

  11. #11
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Select Random Rows and Display on new sheet

    Gees, I seem to have walked into a final, great, working solution here. What more can I say.


    rylo

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Select Random Rows and Display on new sheet

    Fixed a bug!
    Last edited by shg; 05-11-2009 at 02:43 PM. Reason: removed attachment; see http://www.excelforum.com/excel-programming/683181-comma-error-in-programed-combo-box.html#post2090816

  13. #13
    Forum Contributor
    Join Date
    05-18-2004
    Location
    Portland, Oregon
    MS-Off Ver
    2016
    Posts
    182

    Re: Select Random Rows and Display on new sheet

    This is really great stuff!

    It works excellent, for me. I did some quick testing on my co-workers computer and I get an error.

    "Compile Error:
    Can't find project or library."

    Is there something special that I need to do to their excel (their = tried two co-workers, both got the same error)? I do a lot of Macro stuff on my excel so I have many add-ins, though I am not sure exactly what is causing this error.

    I have attached a screen shot of the error.

    Cheers,
    Matt
    Attached Images Attached Images

  14. #14
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Select Random Rows and Display on new sheet

    In the VBE, do Tools > References, and look at the checked items in the list (which are all at the top). One will likely say MISSING. Uncheck it.

  15. #15
    Forum Contributor
    Join Date
    05-18-2004
    Location
    Portland, Oregon
    MS-Off Ver
    2016
    Posts
    182

    Re: Select Random Rows and Display on new sheet

    What I see is attached. I don't see anything that says "Missing". Other thoughts? Perhaps one of the ones I have checked is not necessary.

    Regards,
    Matt
    Attached Images Attached Images

  16. #16
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Select Random Rows and Display on new sheet

    That's what you see on your computer, or what you see on theirs?

  17. #17
    Forum Contributor
    Join Date
    05-18-2004
    Location
    Portland, Oregon
    MS-Off Ver
    2016
    Posts
    182

    Re: Select Random Rows and Display on new sheet

    Nevermind. I got it to work. Thanks for your hint and suggestion on where to look.

    Again, I very much appreciate your help, this has been a fun learning experience.

    Cheers,
    Matt

  18. #18
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Select Random Rows and Display on new sheet

    You’re welcome. Would you please mark the thread as Solved?

    Click the Edit button on your first post in the thread

    Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes

  19. #19
    Registered User
    Join Date
    07-02-2009
    Location
    bangalore
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Select Random Rows and Display on new sheet

    This is what exactly i am looking for a training project of mine.

    i have a set of 500 questions which i wish to give randomly to the participants of a technical training program.

    can some one please, share with me the code.


    i dont need answers to pop up. i have a page of 500 rows and 1 random row has to appear on a seperate page. thats all.

    can some one please help.

    thanks in advance,
    sravan

  20. #20
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Select Random Rows and Display on new sheet

    Welcome to the forum.

    Please take a few minutes to read the forum rules, and then start your own thread.

  21. #21
    Registered User
    Join Date
    02-09-2011
    Location
    perth, wa
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Select Random Rows and Display on new sheet

    Quote Originally Posted by shg View Post
    Here's a start ...
    I would be grateful if you could reattach the solution to this query. I'm trying to do a similar thing i.e select random rows from one worksheet and display them on a different worksheet. Many thanks in advance.

  22. #22
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Select Random Rows and Display on new sheet

    Here you go ...
    Attached Files Attached Files

  23. #23
    Registered User
    Join Date
    11-25-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Select Random Rows and Display on new sheet

    This is similar to the one that I'm doing. The only difference is that the source data is filtered and I need to copy random rows from the filtered table and paste to a new worksheet. Can you help me on this?

    Thank you so much in advance.
    Last edited by faye g; 02-27-2013 at 06:24 AM.

  24. #24
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Select Random Rows and Display on new sheet

    Faye,

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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