View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen[_2_] Per Jessen[_2_] is offline
external usenet poster
 
Posts: 703
Default Sum after every blank cell

On 28 Jan., 00:18, wrote:
Hello,

I love this website!! I have a problem that I am going nuts over. In
column A I have several numbers from A1 to A100
In that column there may be random blank spaces like A10 is blank, A15
is blank then A40 is blank.I would like a formula in column B that
sums A1to A9 then sums A11 to A14. Inotherwords, is there a formula
that will give me a sum after there is a blank cell?
Thanks


Hi

Try this macro.

Sub AddSumIfBlank()
Range("B1:B101").ClearContents
tCell = "A1"
tCell1 = "A1"
For c = 0 To 100
If Range(tCell).Offset(c, 0) = "" Then
tCell2 = Range(tCell).Offset(c, 0).Address
Range(tCell2).Offset(0, 1).Formula = "=SUM(" & tCell1 & ":" &
tCell2 & ")"
tCell1 = tCell2
End If
Next
End Sub


Regards,

Per