Accumulated Amount Problem - Excel VBA

  • Thread starter Thread starter henrycheung
  • Start date Start date
H

henrycheung

How to write VBA for the accumulated amount column which could
automatically be entered when the charge column has been inputted.

Description Charge Accumulated Amount

Toys 200 200
Bags 350 550
Books 400 950


Thanks
 
Hi

one solution without VBA just Excel formulas
In the first cell for your accumulated amount (assumption: cell C2)
enter the following
=IF(B2<>"",B2,"")
in cell C3 enter the following:
=IF(B3<>"",C2+B3,"")
copy this formula down

HTH
Frank
 
Henry,

This goes in the worksheet code module

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit
If Target.Column = 2 Then
Target.Offset(0, 1).FormulaR1C1 = "=sum(R1C[-1]:R" & Target.Row &
"C[-1])"
End If

ws_exit:
Application.EnableEvents = True
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top