Thanks to your help here at the VB forum I have almost created an excellent accounting tool; unfortunately there are still flaws. Below is the code that I have been working on. For every cell in range “RA” it adds combinations of two cells in Range “RB” until it finds the two that equal the cell in range “RA.” So far it has been about 60% successful at finding all of the combinations of two cells in range “RB” whose sum equals the cells in “RA;” but for reasons unknown to me it does not find all of them. Can someone help me figure out why it misses some and what I can do about it?
VB Code:
Range("e1").Select Range(Selection, Selection.End(xlDown)).Select Selection.Name = "RB" Range("f1").Select Range(Selection, Selection.End(xlDown)).Select Selection.Name = "RA" Dim RangeA As Range Dim RangeB As Range Dim CellA As Range Dim CellB As Range Dim CellC As Range Set RangeA = Range("RA") Set RangeB = Range("RB") For Each CellA In RangeA.Cells For Each CellB In RangeB.Cells For Each CellC In RangeB.Cells If CellB + CellC = CellA Then CellA.ClearContents CellB.ClearContents CellC.ClearContents End If Next CellC Next CellB Next CellA




Reply With Quote