Hi All,
I want to create the following algorithm however can't seem to get the loops the right way round and was hoping to get a bit of help.
Hints rather than full solutions would be appreciated as this is more we wanting to learn than to get this to work
Say I have 5 cells. I want the algorithm to do this
Debug.Print:
(Sum 1)
Cell(C)1
C2
C3
C4
C5
(Sum 2)
C1+C2
C1+C3
C1+C4
C1+C5
C2+C3
C2+C4
C2+C5
C3+C4
C3+C5
C4+C5
(Sum 3)
C1+C2+C3
C1+C2+C4
C1+C2+C5
C1+C3+C4
C1+C3+C5
C1+C4+C5
C2+C3+C4
C2+C3+C5
C2+C4+C5
C3+C4+C5
(Sum 4)
C1+C2+C3+C4
C1+C2+C3+C5
C1+C2+C4+C5
C1+C3+C4+C5
C2+C3+C4+C5
(Sum 5)
C1+C2+C3+C4+C5
So in short: The outer-loop will be going from 1 to N products (where N is the last cell e.g. 5 in my example)
Then it starts with
For n = 1 to N
i=1: Ci + C(i+1) + C(i+2) + ... + C(i+N-1)
i=1: Ci + C(i+1) + C(i+2) + ... + C(i+N-1+1)
i=1: Ci + C(i+1) + C(i+2) + ... + C(i+N-1+2)
i=1: Ci + C(i+1) + C(i+2) + ... + C(i+N-1+j)
...
Till (i+N-1+j)=N
Then to increment the product before by one
i=1: Ci + C(i+1) + C(i+2+1) + ... + C(i+N-1+1)
And then repeat the iteration of the the last combo till it reaches N; then iterate the cell before by 1 again, repeat. Once the cell before = N, iterate the cell before that by 1 and then repeat.
Hope this makes sense! Thank you!
I want to create the following algorithm however can't seem to get the loops the right way round and was hoping to get a bit of help.
Hints rather than full solutions would be appreciated as this is more we wanting to learn than to get this to work
Say I have 5 cells. I want the algorithm to do this
Debug.Print:
(Sum 1)
Cell(C)1
C2
C3
C4
C5
(Sum 2)
C1+C2
C1+C3
C1+C4
C1+C5
C2+C3
C2+C4
C2+C5
C3+C4
C3+C5
C4+C5
(Sum 3)
C1+C2+C3
C1+C2+C4
C1+C2+C5
C1+C3+C4
C1+C3+C5
C1+C4+C5
C2+C3+C4
C2+C3+C5
C2+C4+C5
C3+C4+C5
(Sum 4)
C1+C2+C3+C4
C1+C2+C3+C5
C1+C2+C4+C5
C1+C3+C4+C5
C2+C3+C4+C5
(Sum 5)
C1+C2+C3+C4+C5
So in short: The outer-loop will be going from 1 to N products (where N is the last cell e.g. 5 in my example)
Then it starts with
For n = 1 to N
i=1: Ci + C(i+1) + C(i+2) + ... + C(i+N-1)
i=1: Ci + C(i+1) + C(i+2) + ... + C(i+N-1+1)
i=1: Ci + C(i+1) + C(i+2) + ... + C(i+N-1+2)
i=1: Ci + C(i+1) + C(i+2) + ... + C(i+N-1+j)
...
Till (i+N-1+j)=N
Then to increment the product before by one
i=1: Ci + C(i+1) + C(i+2+1) + ... + C(i+N-1+1)
And then repeat the iteration of the the last combo till it reaches N; then iterate the cell before by 1 again, repeat. Once the cell before = N, iterate the cell before that by 1 and then repeat.
Hope this makes sense! Thank you!
Last edited: