Hey guys, I need some help. I've been frying my brain trying to get a formula but all I get is a circular reference. Someone told me to write a macro to do it which I have no clue how to do.
I have the following 6 columns:
1. Column A: Day {Mon..Sun}
2. Column B: Demand [kg]
3. Column C: Initial Level [kg] (initial level of day n = final level of day n-1 except for day 1)
4. Column D: Delivery day {yes/no} (usually Mon..Fri are Delivery day while Sat&Sun are not)
5. Column D: Number of trucks {int}
6. Column E: Final level [kg] (formula: initial level - demand +#truck*truck capacity)
Also 3 constants:
truck capacity = value of cell R2
initial level = value of cell R3
study length = value of cell R4 (number of days for the study)
What I need is a macro that will fill column D: Number of trucks given a certain criteria. If the final level of the day is below 0, then I need a truck to arrive on that day to offload 20 kg so I don't get a stockout. If one truck is not enough, then I need another and so on.
In my rudimentary logic, I tried writing the algorithm below to try to explain it better
Is today is "Delivery Day"
y: Is tomorrow "Delivery Day" [or the next n consecutive days]
| y: Is Final level of today <0
| . y: increase cell in col.D by 1 (bring one truck today)
| . n: go to next day
| n: Is Final level of today or tomorrow <0
| . y: increase cell in col.D by 1 (bring one truck today)
| . n: go to next day
n: go to next day
repeat for: study length [days]
Can you please help me out?
Regards and thanks
I have the following 6 columns:
1. Column A: Day {Mon..Sun}
2. Column B: Demand [kg]
3. Column C: Initial Level [kg] (initial level of day n = final level of day n-1 except for day 1)
4. Column D: Delivery day {yes/no} (usually Mon..Fri are Delivery day while Sat&Sun are not)
5. Column D: Number of trucks {int}
6. Column E: Final level [kg] (formula: initial level - demand +#truck*truck capacity)
Also 3 constants:
truck capacity = value of cell R2
initial level = value of cell R3
study length = value of cell R4 (number of days for the study)
What I need is a macro that will fill column D: Number of trucks given a certain criteria. If the final level of the day is below 0, then I need a truck to arrive on that day to offload 20 kg so I don't get a stockout. If one truck is not enough, then I need another and so on.
In my rudimentary logic, I tried writing the algorithm below to try to explain it better
Is today is "Delivery Day"
y: Is tomorrow "Delivery Day" [or the next n consecutive days]
| y: Is Final level of today <0
| . y: increase cell in col.D by 1 (bring one truck today)
| . n: go to next day
| n: Is Final level of today or tomorrow <0
| . y: increase cell in col.D by 1 (bring one truck today)
| . n: go to next day
n: go to next day
repeat for: study length [days]
Can you please help me out?
Regards and thanks