+ Reply to Thread
Results 1 to 7 of 7

Random Selection from population in different worksheet

  1. #1
    Valued Forum Contributor ron2k_1's Avatar
    Join Date
    09-30-2009
    Location
    Not the USA
    MS-Off Ver
    Excel 2003, 2007
    Posts
    606

    Random Selection from population in different worksheet

    Good day,

    Kindly refer to attachment. The objective is pretty easy. The worksheet "Sample Size" already calculated that from total population pasted in Worksheet "Population", I need to select 112 accounts (Sample Size cell C20). So now, I want my chopped up macro to randomly select 112 from the list in "Population" and generate the list on "Sample Size" Worksheet cell A24 onwards. Don't try my macro, it hangs up and will freeze your computer. I'd really appreciate it if you can audit my macro and school me where I went wrong.

    Thanks,

    Ron
    Attached Files Attached Files
    Ron
    Knowledge is knowing that a tomato and pepper are fruits. Wisdom is knowing whether to put these in a fruit salad

    Kindly

    [1] Use code tags. Place "[code]" before the first line of code and "[/code"]" after the last line of code. Exclude quotation marks
    [2] Mark your post [SOLVED] if it has been answered satisfactorily by editing your original post in advanced mode.
    [3] Thank (using the little scale) those that provided useful help; its nice and its very well appreciated

  2. #2
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Random Selection from population in different worksheet

    There's probably a faster way, but the procedure below is pretty straightforward:

    Please Login or Register  to view this content.
    It basically copies the entire set over to sheet 2, then deletes rows down to 112 (or whatever is in C20). Give it a go, see if it'll do.

  3. #3
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,223

    Re: Random Selection from population in different worksheet

    Dear Ron
    Refer attach file.
    You want to do by macro. But i am sorry to say that, i am not familier with vba micro, hence by formula i do this. I think this also usable for all excel forum members.
    In sample size sheet in "A24" i am using =row, =counta, =index, =large, =countif & =randbetween formula based on sheet "population column "A" and "B".

    In "A24"
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    In "B24"
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Array formula ensure [SHIFT+CTRL+ENTER]
    Attached Files Attached Files


    atul


    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved".

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Random Selection from population in different worksheet

    Hers is another.

    With help from link below
    cpearson

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  5. #5
    Valued Forum Contributor ron2k_1's Avatar
    Join Date
    09-30-2009
    Location
    Not the USA
    MS-Off Ver
    Excel 2003, 2007
    Posts
    606

    Re: Random Selection from population in different worksheet

    Quote Originally Posted by mike7952 View Post
    Hers is another.

    With help from link below
    cpearson

    Please Login or Register  to view this content.
    Thank you sir. I made some changes to clear the sample history every time I run the macro. However, I need help with one more thing.

    Row 1 in the Population sheet is being taken as a sample item as well. The header needs to be excluded. I can't seem to locate the line I need to change.

    Thanks.

    Ron

  6. #6
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Random Selection from population in different worksheet

    this should do it

    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor ron2k_1's Avatar
    Join Date
    09-30-2009
    Location
    Not the USA
    MS-Off Ver
    Excel 2003, 2007
    Posts
    606

    Re: Random Selection from population in different worksheet

    Quote Originally Posted by mike7952 View Post
    this should do it

    Please Login or Register  to view this content.
    Yep. It seems so. Thanks so much. Thanks everybody else as well.

    Regards,

    Ron

+ 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. Random selection option, same 'random' selection in two columns
    By applebanana in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-01-2016, 06:16 PM
  2. Population of Worksheet using VBA from Outlook
    By ARGK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-09-2016, 01:23 PM
  3. [SOLVED] World Population Random Generator
    By PaperArrow in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-14-2015, 05:51 PM
  4. Selection of Optionbutton control population of data in combobox
    By PaulBas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-15-2014, 12:32 PM
  5. Random Selection and Random Numbers
    By thepassfan in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-05-2014, 04:48 PM
  6. Data Population Into Worksheet with VBA
    By scrags in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-03-2012, 08:45 AM
  7. Taking a random sample from a population of names/contacts
    By whitnd4 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-19-2009, 11:56 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