• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to copy and paste random rows from one sheet to another with some conditions

mkum32

New Member
Hi,
I am working on a Tool where i require when i click on randomizer button that is in "sheet 1" and select Team, no. of questions and Total scores required, it will randomly pick that number of questions from Sheet2 (i.e, database) for that total marks and paste it in Sheet 1 in Questionnaire column.
I am able to filter the questions as per the team selected and can paste in the field required but unable to set the conditions of number of "questions" and "Total Score Required" and copy and paste the random questions in sheet 1.
I have attached the file as well. Please help me resolving this issue
 

Attachments

  • PKT Demo.xlsm
    39.2 KB · Views: 6
Hi, mkum32!
Three points:
1) For adding more filtering criteria just repeat the Autofilter method
Code:
ActiveSheet.Range("$A$1:$G$301").AutoFilter Field:=6, Criteria1:=Sheets("Sheet1").Range("B4")
changing the Field no. (column) and the Range("Bx") for the other parameters.
2) I don't see a score column in the data workhseet, so I don't know how or if the score should be matched.
3) With the Copy method you can't restrict the no. of questions copied. I leave you this as homework.
Regards!
 
Thank you for response.
But let me clarify that i am not at all trained in macros, so i have recorded those macros(module) instead of writing it. Is it possible to pick up random 5 questions after that first filter(which is on Team Column)?
If yes, then can you please provide those macros.
 
Hi, mkum32!
Yes, it's possible to do that, but the code wouldn't be the same. You'll have to simulate the randomization and count the n questions required. Still you have the problem of scoring, which I think it's to be included in the random selection.
Please clarify how the score value entered in cell B10 is checked against the questions.
Regards!
 
Well! leave that score value in cell B10, i don't need that anymore. I just need the random number of questions which i enter in B7.
Thank you!
 
Back
Top