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