Sum after every blank cell
On 28 Jan., 04:32, wrote:
The macro works PERFECT. Can this only be achieved by macro or is
there a formula that can create the same results?
Sorry, but this can only be achieved by macro:-(
If you want the macro to run every time a number is entered or deleted
from the target range, try to put this in the macro sheet related to
the sheet containing the data.
Private Sub Worksheet_Change(ByVal Target As Range)
Set isect = Intersect(Range("A1:A100"), Target)
If Not isect Is Nothing Then
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 If
End Sub
Regards,
Per
|