View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Myrna Larson Myrna Larson is offline
external usenet poster
 
Posts: 863
Default auto sum macro if data is present above the cell

I will give you some code tomorrow morning.

On Thu, 21 Oct 2004 18:49:14 -0500, onesaint
wrote:


total needs to be underneath ive come up with this but it isnt looping
to the next area of data this is it;


Sub A_This_one_works()
Dim rwIndex As Integer
Dim colIndex As Integer
Dim i As Integer

colIndex = 14
For rwIndex = 1 To 5
If Cells(rwIndex, colIndex).Value < 0 Then
i = i + 1
End If
Next rwIndex

If Range("L14").End(xlUp).Offset(1, 0).Select = "" Then
Selection.FormulaR1C1 = "=SUM(R[" & -i & "]C:R[-1]C)"
End If

Selection.FormulaR1C1 = "=SUM(R[" & -i & "]C:R[-1]C)"

End Sub

im not real sure how it works my self(not good programming practices)
but in paying around i got it to go. if i change the colindex and the
Range its goes to the last set of numbers and sums those. and lastly
the blank cell is allready under the last number in the set of data.
thanks for all your help i realy do appreciate it.