# Macro Generate Numbers with Condition

#### joram7

##### Board Regular
I need help with a macro where numbers are auto generated in the highlighted yellow cell based on the condition below. The numbers should be trigger based on the percentage allocated.

Condition
For Scenario A,B,C all total must be equal or higher than Cost A
Round up to 0 decimal
All scenario are trigger by the percentage allocation ( % is determine mannualy)

Scenario B
Domestic must be 30
Regional must not be lower than 30 and higher than 60
International must be 60 or higher

Scenario C
Domestic must be 30
International must not be lower than 30
Sample - Mr-excel question.xls
CDEFGHI
8
9
10NumberofCount1,0001,0001,000
11
12
13ScenarioABC
14
15RangeValueRangeValueRangeValue
16International59Domestic30Domestic30
17Regional55International80
18International65
19
20
21
22
23TierAllocationRangePercentageRangePercentageRangePercentage
24Tier1International100.0%Domestic20.0%Domestic10.0%
25Tier2 Regional50.0%International90.0%
26Tier3 International30.0%
27Tier4
28Tier5
29
30
31
32Total59,00053,00075,000
33CostA58,21158,21158,211
34
35
Fee_Scenario

### Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

#### joram7

any help?

##### Well-known Member
Your information doesn't make much sense.

Solve for International, Domestic and Regional and you get 1000, 333.333... and -400 respectively. How you're determining anything is totally unknown to us. Try explaining more clearly with a step-by-step example of how you'd solve the problem now, what your logic is, and where you're getting your data from.

#### tusharm

##### MrExcel MVP
Take a look at Excel's Solver (Tools | Solver...) You can use it to adjust the % numbers so that the final numbers match your requirement.
I need help with a macro where numbers are auto generated in the highlighted yellow cell based on the condition below. The numbers should be trigger based on the percentage allocated.

Condition
For Scenario A,B,C all total must be equal or higher than Cost A
Round up to 0 decimal
All scenario are trigger by the percentage allocation ( % is determine mannualy)

Scenario B
Domestic must be 30
Regional must not be lower than 30 and higher than 60
International must be 60 or higher

Scenario C
Domestic must be 30
International must not be lower than 30

{snip}

Replies
6
Views
527
Replies
19
Views
712
Replies
8
Views
488
Replies
3
Views
358
Replies
3
Views
774

1,195,833
Messages
6,011,853
Members
441,650
Latest member
ceyoung75

### 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.

### Which adblocker are you using?

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

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