complicated bank rec - how can I add it up?
A rather complicated bank rec.
I have a large list of receipts in column A, and a smaller list of bank deposits in column B. I need to match them up, but other than trial and error, is there a way in excel (or otherwise) of calculating the sum of all combinations of (1...n) figures in the column.
For example, (highly simplified)
Column A Column B
6 27
42 142
21 126
97 118
104
3
22
118
Trial and error shows that 27= 6+21
142 = 42+97+3
and 126 = 104+22
and 118 = 118
But difficult with hundreds of figures
Thanks
Andrew
There is or was a thread that gave an answer of sorts to a simil
but it's was a bit hit and miss in my experience, and I cannot remeber how exactly. It was a few years back and I cannot immediately find the thread.
In any event I think you would still have to work through each total one at a time.
Anyone remember "SuperCalc".
Possibly some highly complex "what-if" calculation?
I'm no expert at excel, but after using spreadsheets Excel, and before that SuperCalc (anyone remember that?), for it must be 30 years, I reckon Im pretty clued up - but I cant think of a way to do what you're suggesting.
Paying in book?
Is there no paying in book?
Any dates at all?
It looks to me that you have a complicated problem. What I would do is form a spreadsheet with receipts in one column and deposits is one line. Your sum figure to be above the deposit line, in effect your objective. Then you copy over to the summed column, above the objective, on a trial & error basis. I do not know how jumbled the receipts are, but you may find that there is a limited number of possible deposit dates. If however a January receipt is mixed in with one in March and another in May - and it is all like that - then you may have to accept the time taken will be excessive. As such you may have to consider the total difference between receipts & deposits and how you deal with that.
Need a human
When I have a really big reconciliation I sort the transactions by different values, dates, references, amounts and when I am able to agree anything or even match with differences I move them up the spreadsheet to areas that say "matched" or "related". As you do that - make sure you have totals and a difference column for every line so that no errors creep in - slowly it becomes more manageable.
You're unlikely to get a reconciliation that match from pure mathematics so you are better of having a human in charge doing the thinking with excel making sure you don't make any mistakes.
Powerset
I was asked a very similar question around Christmas and referred it to my maths student son, who suggested an answer would be based on the 'powerset' of all the numbers in the range. The following might help at least define the problem:
http://www.tushar-mehta.com/excel/tips/powerset.html
He wrote a quick bit of code that solved a problem with a dozen or so values, but I think it might start gettting prohibitively complicated for lots of values.
Supercalc
On a dos machine - why would you want anything else.
Might be able to help
One of my friends (and a client) who is a software developer wrote a programme for me when I had the same problem.
He did it in an evening and it is no frills but it worked.
You couldn't put in hundreds of figures as it would take forever to calculate it but up to 15 numbers would take about a minute to calculate the combination.
Is this any help or do you need something more powerful?
thanks bigdave - can you send me a copy
if you could email me a copy to andrew@tiekeyaccounts.co.uk I'd be extremely greatful.
Downloadable Spreadsheet
You can download a spreadsheet that does this for you from the following link:
http://www.dailydoseofexcel.com/archives/2005/10/27/which-numbers-sum-to-target/
found the answer
I have answered my own question, and marked it as best answer. This is Aweb at its best! Thanks everyone for the fantastic posts in this thread,
I found it here http://www.tushar-mehta.com/excel/templates/match_values/index.html#VBA_multiple_combinations
As far as I can tell the code below is easy to understand and is also probably about as fast as one can get. Put the code below in a standard module. (Press alt-f11 then click on "insert" on the menubar, then "module" then paste the code in, then exit back to excel
The data for the search should be organized in a single contiguous range in one column.
| The first cell contains the maximum number of solutions to be found. If the cell contains zero all solutions will be found. |
| The second cell contains the target value. |
| The values that are to be matched follow. |
Select the range containing all the information (the cell indicating the maximum number of solutions, the target value, and all the values to be matched), and use ALT+F8 to run the startSearch procedure.
Option Explicit
Function RealEqual(A, B, Epsilon As Double)
RealEqual = Abs(A - B) <= Epsilon
End Function
Function ExtendRslt(CurrRslt, NewVal, Separator)
If CurrRslt = "" Then ExtendRslt = NewVal _
Else ExtendRslt = CurrRslt & Separator & NewVal
End Function
Sub recursiveMatch(ByVal MaxSoln As Integer, ByVal TargetVal, InArr(), _
ByVal CurrIdx As Integer, _
ByVal CurrTotal, ByVal Epsilon As Double, _
ByRef Rslt(), ByVal CurrRslt As String, ByVal Separator As String)
Dim I As Integer
For I = CurrIdx To UBound(InArr)
If RealEqual(CurrTotal + InArr(I), TargetVal, Epsilon) Then
Rslt(UBound(Rslt)) = (CurrTotal + InArr(I)) _
& Separator & Format(Now(), "hh:mm:ss") _
& Separator & ExtendRslt(CurrRslt, I, Separator)
If MaxSoln = 0 Then
If UBound(Rslt) Mod 100 = 0 Then Debug.Print UBound(Rslt) & "=" & Rslt(UBound(Rslt))
Else
If UBound(Rslt) >= MaxSoln Then Exit Sub
End If
ReDim Preserve Rslt(UBound(Rslt) + 1)
ElseIf CurrTotal + InArr(I) > TargetVal + Epsilon Then
ElseIf CurrIdx < UBound(InArr) Then
recursiveMatch MaxSoln, TargetVal, InArr(), I + 1, _
CurrTotal + InArr(I), Epsilon, Rslt(), _
ExtendRslt(CurrRslt, I, Separator), _
Separator
If MaxSoln <> 0 Then If UBound(Rslt) >= MaxSoln Then Exit Sub
Else
'we've run out of possible elements and we _
still don't have a match
End If
Next I
End Sub
Function ArrLen(Arr()) As Integer
On Error Resume Next
ArrLen = UBound(Arr) - LBound(Arr) + 1
End Function
Sub startSearch()
'The selection should be a single contiguous range in a single column. _
The first cell indicates the number of solutions wanted. Specify zero for all. _
The 2nd cell is the target value. _
The rest of the cells are the values available for matching. _
The output is in the column adjacent to the one containing the input data.
Dim TargetVal, Rslt(), InArr(), StartTime As Date, MaxSoln As Integer
StartTime = Now()
MaxSoln = Selection.Cells(1).Value
TargetVal = Selection.Cells(2).Value
InArr = Application.WorksheetFunction.Transpose( _
Selection.Offset(2, 0).Resize(Selection.Rows.Count - 2).Value)
ReDim Rslt(0)
recursiveMatch MaxSoln, TargetVal, InArr, LBound(InArr), 0, 0.00000001, _
Rslt, "", ", "
Rslt(UBound(Rslt)) = Format(Now, "hh:mm:ss")
ReDim Preserve Rslt(UBound(Rslt) + 1)
Rslt(UBound(Rslt)) = Format(StartTime, "hh:mm:ss")
Selection.Offset(0, 1).Resize(ArrLen(Rslt), 1).Value = _
Application.WorksheetFunction.Transpose(Rslt)
End Sub
now I'm getting into this....
More links for anyone who's interested...
http://www.mrexcel.com/pc09.shtml
http://groups.google.com/groups?as_q=match+numbers+sum+target&as_ugroup=*Excel*
another way without code
One way but you need the solver add-in installed (it comes with
excel/office,check under tools>add-ins)
put the data set in let's say A2:A8, in B2:B8 put a set of ones {1,1,1 etc}
in the adjacent cells
in C2 put 8, in D2 put
=SUMPRODUCT(A2:A7,B2:B7)
select D2 and do tools>solver, set target cell $D$2 (should come up
automatically if selected)
Equal to a Value of 8, by changing cells $B$2:$B$7, click add under Subject
to the constraints of:
in Cell reference put
$B$2:$B$7
from dropdown select Bin, click OK and click Solve, Keep solver solution
and look at the table
2 1
4 0
5 0
6 1
9 0
13 0
there you can see that 4 ones have been replaced by zeros and the adjacent
cells to the 2 ones
total 8
Takes ages for large amounts of data though
ISOLIST MOVERVE
Have a look at:
http://moverve.com/isolist/reconciliation.php
and in particular
http://moverve.com/isolist/data-reconciliation.php#one-to-many
It's always worked for me and it's not that expensive.
God luck
Chris
Lyquidity Find Combinations Add-in
The problem you need to solve here is infamous enough to have its own name - the "subset sum" problem. In the general case there are no efficient algorithms to solve it. However it can be solved, within limits, using brute force.
I recommend you take a look at this free Excel add-in (link below). I haven't yet used it myself but it is from a reputable development firm and is designed to solve your problem.
www.lyquidity.com/mambo/index.php
Jim










I doubt it
I'm pretty certain there is no way - you're asking excel to do something that is not down to pure calculation.
if anyone does know how to do this I'll be amazed - and interested.