Hallo,
Hope someone can help me with this request.
I have numbers between 4 and 24 in the column B(from cell B2 to B161).
I want to fill the cells in the column C with 1 to 63, based on the sum of the cells in column B.
If the sum of continuous cells in column B(minimum 1 and maximum 5 cells) is <= 24, then fill 1 for those corresponding cells in column C. Then jump to next cells and repeat the same procedure and fill 2 and so on.
In this sample, the sum of B2 to B6(5 cells) is 20, so fill C2 to C6 with 1.
Sum of B7 to B10 is 21(adding B11 makes is 29), so fill C7 to C11 with 2.
At B16, adding B17 makes is 27, so C16 filled with 5.
Can this be achieved with formulas?
Looks like it is possible with a for loop and if loops in a VBA, but I'm not good in it.
Thanks in advance.
Kind regards,
Janu
Hope someone can help me with this request.
I have numbers between 4 and 24 in the column B(from cell B2 to B161).
I want to fill the cells in the column C with 1 to 63, based on the sum of the cells in column B.
If the sum of continuous cells in column B(minimum 1 and maximum 5 cells) is <= 24, then fill 1 for those corresponding cells in column C. Then jump to next cells and repeat the same procedure and fill 2 and so on.
In this sample, the sum of B2 to B6(5 cells) is 20, so fill C2 to C6 with 1.
Sum of B7 to B10 is 21(adding B11 makes is 29), so fill C7 to C11 with 2.
At B16, adding B17 makes is 27, so C16 filled with 5.
Can this be achieved with formulas?
Looks like it is possible with a for loop and if loops in a VBA, but I'm not good in it.
Thanks in advance.
Kind regards,
Janu
Fill_Numbers.xlsx | |||||
---|---|---|---|---|---|
A | B | C | |||
1 | S.No | Count | Fill numbers | ||
2 | 1 | 4 | 1 | ||
3 | 2 | 4 | 1 | ||
4 | 3 | 4 | 1 | ||
5 | 4 | 4 | 1 | ||
6 | 5 | 4 | 1 | ||
7 | 6 | 4 | 2 | ||
8 | 7 | 4 | 2 | ||
9 | 8 | 6 | 2 | ||
10 | 9 | 7 | 2 | ||
11 | 10 | 8 | 3 | ||
12 | 11 | 9 | 3 | ||
13 | 12 | 8 | 4 | ||
14 | 13 | 11 | 4 | ||
15 | 14 | 4 | 4 | ||
16 | 15 | 16 | 5 | ||
17 | 16 | 11 | 6 | ||
18 | 17 | 7 | 6 | ||
19 | 18 | 9 | 7 | ||
20 | 19 | 5 | 7 | ||
21 | 20 | 5 | 7 | ||
22 | 21 | 4 | 7 | ||
23 | 22 | 4 | |||
24 | 23 | 9 | |||
25 | 24 | 6 | |||
26 | 25 | 12 | |||
27 | 26 | 5 | |||
28 | 27 | 12 | |||
29 | 28 | 11 | |||
30 | 29 | 6 | |||
31 | 30 | 5 | |||
32 | 31 | 13 | |||
33 | 32 | 16 | |||
34 | 33 | 4 | |||
35 | 34 | 5 | |||
36 | 35 | 7 | |||
37 | 36 | 8 | |||
38 | 37 | 8 | |||
39 | 38 | 4 | |||
40 | 39 | 4 | |||
41 | 40 | 6 | |||
Sheet2 |