help with spreadsheet calculations
Duke Carey wrote...
At a minimum you will need to use 2 cells and a worksheet change macro.
However, you lose detail and your audit trail by doing this.
....
Picky technical response. I agree about the audit trail, but this
repsonse is limited to the technical issue of using a cell as an
accumulator.
It doesn't require two cells. It only requires trickery. To treat cell
B2 as an accumulator all it takes is something like this.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim t As Variant
If Intersect(Target, Range("B2")).Cells.Count = 1 Then
Set Target = Range("B2")
Else
Exit Sub
End If
On Error Resume Next
Application.EnableEvents = False
t = Target.Value
Application.Undo
Target.Value = Target.Value + t
If Err.Number < 0 Then Target.Value = t
Err.Clear
Application.EnableEvents = True
End Sub
|