Consulting

Results 1 to 5 of 5

Thread: How to pick the random numbers from a set of numbers

  1. #1

    Post How to pick the random numbers from a set of numbers

    Hi all


    Im creating a macro which consists of two excel files.
    in one excel file, there are four fields named Sno,Name ,Ps ID and Case ID. The user will provide Sno,name and PS ID.
    I need to run a macro of which for Each Name, i need to pick 5 CaseIDs Randomly which is presented in a another excel file which has list of CaseIDs .
    I need to check the count of CaseIDs presented in the Second Excel As Well.
    I knew that i need to use Rnd() function. But i dont know how to code it since im very new to excel vba.

    Plz suggest me

    i have posted the original thread in the following forum link
    http://www.ozgrid.com/forum/showthread.php?t=156529

    Ganesh. V
    Last edited by ganesh3084; 07-27-2011 at 03:26 AM.

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Principle:
    In the sheet/workbook with the list of CaseIDs (I guess the IDs are in a single column), add a new column to the table with =RND() in all the cells, sort the table ONCE on that new column, now you can pick off cases in chunks of 5 rows at a time, starting at the top and working your way down the table.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3

    Post

    Quote Originally Posted by p45cal
    Principle:
    In the sheet/workbook with the list of CaseIDs (I guess the IDs are in a single column), add a new column to the table with =RND() in all the cells, sort the table ONCE on that new column, now you can pick off cases in chunks of 5 rows at a time, starting at the top and working your way down the table.
    Hi Thanks for ur timely response. Ya ID are in a single column

    Well actually i need to do these through writting VBA Code. Can u please furnish some sample code regarding..

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Record a macro of you doing it and copy the code here, then we'll tidy it up.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  5. #5

    Post

    Quote Originally Posted by p45cal
    Record a macro of you doing it and copy the code here, then we'll tidy it up.
    thanks
    i will check it and revert

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •