Randomization Based Off a Set of Rules

Kawan

New Member
Joined
Nov 17, 2021
Messages
6
Office Version
  1. 2019
Platform
  1. MacOS
Hi everyone,

I have a rather tricky problem to solve.

For each row in my table (for each person) - refer to screenshot named "My Table", I would like excel to randomly generate a 9 digit number (in Column N) but based on a certain set of rules.

Here is how I currently generate them 1 by 1 manually:

Screen Shot 2021-11-17 at 7.08.27 PM.png


1. Yellow cells: I only modify the numbers of this row.
  • The first 3 digits of this row are based off the person's year of birth (DOB Column in the 'Results' worksheet). A 3 digit code is assigned based on the year of birth (refer to screenshot called "First 3 digits").
  • Then I manually change the last 6 digits of this row one by one so that the green cell equals to an even number ending in 0, so: 10 or 20 or 30 or 40 or 50 or 60, etc.
2. Orange cells:
  • This row is the factor row and never changes, each of the number above it is multiplied by this factor. So in the example above, 3 (in yellow) will be multiplied 1 (in orange), 9 (in yellow) by 2 (in orange), 4 (in yellow) by 1 (in orange), and so fourth.
3. Red cells: The formula for each red cell is the same with the exception of the reference cells in the formula, so for example for cell F5 the formula is:
Excel Formula:
=IF(SUM(F3*F4)>=10,SUM(F3*F4)-9,SUM(F3*F4))

for cell G5 the formula is:

Excel Formula:
=IF(SUM(G3*G4)>=10,SUM(G3*G4)-9,SUM(G3*G4))

4. Green Cell: This cell is just the SUM of of the red cells, so
Excel Formula:
=SUM(F5:N5)
It must always equal to an even number ending in 0, so: 10 or 20 or 30 or 40 or 50 or 60, etc...


To sum it up:

For each row in my table, so for each person (refer to screenshot called "My table" in the results worksheet), I would like excel to generate a random 9 digit number in the column called "9 Digit Number" (Column N) based on the set of rules explained above.

I have thousands of rows so you can understand why I would like this process to be automated.

Please do not hesitate to ask me should you require more clarification/information.

Thank you,
Kawan.
 

Attachments

  • 9 Digits Worksheet.png
    9 Digits Worksheet.png
    253.4 KB · Views: 4
  • My Table - Results Worksheet.png
    My Table - Results Worksheet.png
    101.3 KB · Views: 5
  • First 3 Digits.png
    First 3 Digits.png
    143 KB · Views: 5

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,151,774
Messages
5,766,403
Members
425,350
Latest member
procha

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
Top