Excel Repeating a RAND() function under certain conditions


Joined
Dec 5, 2017
Messages
1
Reaction score
0
Hi,

I have a spreadsheet which has a RAND() function in A1 and another in B1 (function is =TRUNC(30*RAND())+1 to give a random number between 1 and 30)

I want the second number to be a factor of the first, and if it isn't, regenerate the second number until it is.

I was trying to use the MOD() function to do this, and if the MOD() returns 0 (i.e.the number is B1 IS a factor of A1) then it leaves both numbers intact.
If, however, the MOD() function returns anything but 0, so B1 is NOT a factor of A1, then I would like B1 to recalculate the RAND() function and try again...

I will duplicate this across a lot of cells, to make random division problems for my school class.

Hope that makes sense.

Thanks in Advance of your help.

Craig
 
Last edited:
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top