First problem i post myself, and hoping some brilliant minds can help me out.
I’m doing a cash balance, and need an algorithm/macro to find what sums equal to the value in question. And what is needed is the values that adds up to the change in the balance, meaning, in the Buildup below, what values in section 2. Makes the changes equal to section 3. (ending balance)
An easy way to do this, is see what numbers in the balance equals the Ending balance. **(See last part of post for further explaining. )
Buildup of data:
As an extra frustration, Decimals might not be equal, but the Rounded numbers should be the same. (Imprecise I know, but its what I have to work with.)
That will be the buildup, and three different possibilities in the “Array/Column” section 2. from the buildup of the data. The result should be – Beginning balance, +/- the values remaining from section 2 Equals the value in section 3.
Am I making myself clear?
Recap of needs: I need a macro that figures out what transaction# adds up to the Difference (Data at the bottom)
What I am looking for, is suggestions on how to approach this, If a number of a positive value has its negative counterpart I know how to exclude them. Its when a number
Datasample:
<tbody>
</tbody>
**
In my example, the result should be the following:
Beginning cash balance is cancelled out by transaction 16, (this is one transaction here, but might be more than one)
The ending balance is a combination of transactions: 1+2+33+36 = 926227,43 (ending balance)
Meaning all other transactions in between has "cancelled" each-other.
What would be the best approach?
- Find what numbers adds up to the ending balance?
- Exclude all numbers that can be excluded, then look at what you are left with and compare to ending/start?
There are many pit-falls here, all suggestions are welcome!
If I need to explain further or have been unclear, please let me know.
I’m doing a cash balance, and need an algorithm/macro to find what sums equal to the value in question. And what is needed is the values that adds up to the change in the balance, meaning, in the Buildup below, what values in section 2. Makes the changes equal to section 3. (ending balance)
An easy way to do this, is see what numbers in the balance equals the Ending balance. **(See last part of post for further explaining. )
Buildup of data:
- One beginning cash balance, may be zero. (makes it easier)
- Long string/column of data with values +/- (Section 2)(Many values, may differ)
- One ending cash balance. (Section 3)
- One number is equal to another, hence they cancel eachother out. (Trans: 31, 32)
- A number has no counterpart, e.g -100, has no +100 to cancel it out. (Trans: 1)
- A number has many counterpars, e.g -/+100, is cancelled out by -/+10, -/+10 and -/+80
As an extra frustration, Decimals might not be equal, but the Rounded numbers should be the same. (Imprecise I know, but its what I have to work with.)
That will be the buildup, and three different possibilities in the “Array/Column” section 2. from the buildup of the data. The result should be – Beginning balance, +/- the values remaining from section 2 Equals the value in section 3.
Am I making myself clear?
Recap of needs: I need a macro that figures out what transaction# adds up to the Difference (Data at the bottom)
What I am looking for, is suggestions on how to approach this, If a number of a positive value has its negative counterpart I know how to exclude them. Its when a number
Datasample:
Beginning balance | 1368869,01 |
Transaction number | |
1 | -486970,45 |
2 | 413924,88 |
3 | 0 |
4 | -2416321,7 |
5 | -1491107,7 |
6 | 2416321,74 |
7 | 1491107,73 |
8 | 4489910,72 |
9 | 210665,77 |
10 | -210665,77 |
11 | -228539,82 |
12 | 247220,8 |
13 | 228539,82 |
14 | -1766315,8 |
15 | 712271,19 |
16 | -1368869 |
17 | -4489910,7 |
18 | 1766315,8 |
19 | 408379,78 |
20 | -247220,8 |
21 | -670119 |
22 | -712271,19 |
23 | 3269343,93 |
24 | -3269343,9 |
25 | 2622896,89 |
26 | -408379,78 |
27 | -2622896,9 |
28 | -25,61 |
29 | 670119 |
30 | 1268203,93 |
31 | 1268203,93 |
32 | -1268203,93 |
33 | 133483,63 |
34 | 25,62 |
35 | -3303814,9 |
36 | 865789,37 |
37 | -1268203,93 |
38 | 3303814,87 |
Ending cash balance | 926227,43 |
Difference | -442641,58 |
,Difference=Endingbal-Beginningbal |
<tbody>
</tbody>
**
In my example, the result should be the following:
Beginning cash balance is cancelled out by transaction 16, (this is one transaction here, but might be more than one)
The ending balance is a combination of transactions: 1+2+33+36 = 926227,43 (ending balance)
Meaning all other transactions in between has "cancelled" each-other.
What would be the best approach?
- Find what numbers adds up to the ending balance?
- Exclude all numbers that can be excluded, then look at what you are left with and compare to ending/start?
There are many pit-falls here, all suggestions are welcome!
If I need to explain further or have been unclear, please let me know.