Randomization Based Off a Set of Rules

Status
Not open for further replies.

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:

View attachment 51533

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 (refer to screenshot called "First 3 digits"). A 3 digit code is assigned based on the year of birth.
  • 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 red), 9 (in yellow) by 2 (in red), 4 (in yellow) by 1 (in red), 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: 11
  • First 3 Digits.png
    First 3 Digits.png
    169.9 KB · Views: 12
  • My Table - Results Worksheet.png
    My Table - Results Worksheet.png
    101.3 KB · Views: 12

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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:

View attachment 51533

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 (refer to screenshot called "First 3 digits"). A 3 digit code is assigned based on the year of birth.
  • 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 red), 9 (in yellow) by 2 (in red), 4 (in yellow) by 1 (in red), 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.
Also, I noticed I made a mistake here:
It should be:
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.
 
Upvote 0
Duplicate to: Randomization Based Off a Set of Rules

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,397
Messages
6,119,271
Members
448,882
Latest member
Lorie1693

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