Selecting Questions randomly without repeat

Wilson.gadekar

New Member
Joined
Jan 13, 2011
Messages
2
Hello Gurus,

I have prepared a logic in creating a questionaire. But I am looking for anyone to help me prepare a VBA code for it.

I have a sheet with 50 questions and 4 options each. The Code should display 1 question with the options. once the person selects an answer it will verify if the answer is correct then will move forward.

Will then show second question with options and so on for 10 questions only. (The questions should not be repeated)

The logic here which I thought of, is to have an empty array of 50. Everytime the question is selected randomly it is checked with the array if the question already exist if not then displayed. once displayed it will fall into the array for comparing the next question.

Can any one help me on this... Looking for VBA code

Thanks,

Wilson
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
look along these lines
Code:
Sub Get10()
    Dim Pick%, Picked%(50), cc%
    For cc = 1 To 10
        Pick = Int(Rnd() * 50 + 1)
        While Picked(Pick) = 1  ' used so try again
            Pick = Int(Rnd() * 50 + 1)
        Wend
        Picked(Pick) = 1
        Cells(cc, 2) = Pick
        ' do the question routine here for question Pick
    Next cc
End Sub
 
Upvote 0
Wilson,

First we need to know where the 50 questions are...??
Then where you want to put then

if questions in say column D rows 4 to 53
and you want the 10 selected starting in H3 then
something like

range("H2")(cc,1) = range("d3")(pick,1)
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top