Hi All,
I am trying to write an excel VBA loop that which would allow me to sum "count" (col B) in each group until i arrive at the target in (col C), where summing of count would stop at the last row summed which exceeds the target. After which any excess rows for each group will be deleted. To further clarify please see example below.
Example: For the first group "a", the VBA should stop summing at the 3rd cell (sum = 2845) as it is the last sum that exceeds the target of 2800 in col C. Then the entire other remaining 3 rows in group "a" (32, 35, 12) should be deleted.
[TABLE="border: 0, cellpadding: 0, cellspacing: 0"]
[TD="width: 64"]A[/TD]
[TD="width: 64"]B[/TD]
[TD="width: 64"]C[/TD]
Group
[/td]Count
[/td]Target
[/td]a
[/td]
[TD="align: right"]23[/TD]
[TD="align: right"]2800[/TD]
a
[/td]
[TD="align: right"]465[/TD]
a
[/td]
[TD="align: right"]2357[/TD]
a
[/td]
[TD="align: right"]32[/TD]
a
[/td]
[TD="align: right"]35[/TD]
a
[/td]
[TD="align: right"]12[/TD]
b
[/td]
[TD="align: right"]56[/TD]
[TD="align: right"]200[/TD]
b
[/td]
[TD="align: right"]98[/TD]
b
[/td]
[TD="align: right"]34[/TD]
b
[/td]
[TD="align: right"]9[/TD]
b
[/td]
[TD="align: right"]54[/TD]
c
[/td]
[TD="align: right"]670[/TD]
[TD="align: right"]300[/TD]
c
[/td]
[TD="align: right"]2349[/TD]
c
[/td]
[TD="align: right"]87[/TD]
c
[/td]
[TD="align: right"]23[/TD]
[/TABLE]
I have also attached the excel template if required. Please help!!!
Thank you.
Regard,
NC