# Random Question Generator

#### Joda

##### New Member
Hi, after a bit of help, what i am trying to do is design a random question generator for somethign i am doing at work, has to be done within access or excel. This is what i am trying to achieve..

100 Questions, broken down into 5 categories. and it will lets say choose 2 random questions from each section, to make a small exam.

Anyone available to help as have been scratching my head, have workd out how to create a whole random number, and also messed about with LOOKUP and VLOOKUP but cant seem to get that working properly, let alone figured out how to ensure it doesnt pick the same question twice in the same run.

anyone help :x

#### antoka05

##### New Member
To generate a random number you can use this function:
=Int(Rand() * (<max number> - <min number> + 1)) + <min number>
where <min number> and <max number> are min and max value

Then, to get data from a random row, you can use =index(matrix, row, column).
Regards,

Antonio

#### jbeaucaire

##### Well-known Member
Check out this file on my site:

I added a second sheet showing how the technique can be used to grab 2 items from each section. There can be no duplicates in any one test.

#### Misca

##### Well-known Member
Not sure if you want this to be done with a normal function or by a macro but these links should answer your first question:

http://www.ozgrid.com/Excel/excel-random-pick.htm (= Excel)
http://www.techonthenet.com/excel/formulas/rnd.php (= VBA)

Making sure the random numbers are not the same is quite easy in VBA but how to make sure it won't happen in Excel is a bit trickier. I'd try to solve it with by placing the "normal" RANDBETWEEN function in the first cell and then putting the same function twice in an IF function for the second cell (The logic being "if the functions return same values then try again").

I tried this with

=IF(RANDBETWEEN(1,2)=A1,RANDBETWEEN(1,2),RANDBETWEEN(1,2))

several times and never got the same values so it seems to work.

#### Joda

##### New Member
Check out this file on my site:
I added a second sheet showing how the technique can be used to grab 2 items from each section. There can be no duplicates in any one test.

This works a treat for what i need :D

Many thanks