Thread: loop and sum
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jenna Jenna is offline
external usenet poster
 
Posts: 20
Default loop and sum


bernie

The only problem is have with the formula is after the test is true i want
that value in column D instead of the total


thanks so far
"Bernie Deitrick" wrote:

Jenna,

Your summed range at the end:

SUM($C$1:C2)

is wrong. It should be column D:

=IF(SUM($C$1:C3)-SUM($D$1:D2) 3500,SUM($C$1:C3)-SUM($D$1:D2),"")

HTH,
Bernie
MS Excel MVP



"jenna" wrote in message
...
Hii

I would prefer the formula but i'think its a dead end

here's my formula

=IF(SUM($C$1:C3)-SUM($D$1:D2) 3500,SUM($C$1:C3)-SUM($C$1:C2),"")
the problem is after the IF is true i want the formula to start from the
nest row

is possible let me know.

thanks

"Bernie Deitrick" wrote:

Jenna,

Put this formula into cell D2, and copy down to match your column C:

=IF(SUM($C$1:C2)-SUM($D$1:D1) 3500,SUM($C$1:C2)-SUM($D$1:D1),"")

Otherwise, you could use this macro:

Sub SumC()
Dim myC As Range
Dim mySum As Double
mySum = 0
For Each myC In Intersect(Range("C2:C65536"), _
ActiveSheet.UsedRange)
mySum = mySum + myC.Value
If mySum 3500 Then
myC(1, 2).Value = mySum
mySum = 0
End If
Next myC
End Sub

HTH,
Bernie
MS Excel MVP


"jenna" wrote in message
...

Please help

i need a procedure to loop down column c and the first row where the
sum is
greater than 3500 put that amount in the adjacent column, then repeat
from
the next row down.

thanks