PDA

View Full Version : Running total



alphay
03-03-2006, 09:11 AM
Hello there

I am trying to do a running total, as we all know the first cell is A1, that first row is where the runing total will be. I have created a button such that when it is clicked a row is inserted, when a figure is entered in A1 and across, Row A2 becomes the total row and when the button is clicked again another row is inserted, figures are entered across and a running total will be in Row A3 subsequently. This is what i have done so far:

Accounts.Activate
Range("A1").Select
Selection.EntireRow.insert
can anyone help please?

many thanks

phay

mdmackillop
03-03-2006, 02:41 PM
Hi alphay,
Welcome to VBAX
The following code will works after the spreadsheet is "initialized". Insert a value in A1 and =A1 in A2. Thereafter the code will insert the appropriate formula.
Regards
MD


Sub InsRow()
Range("A1").EntireRow.Insert
Cells(Cells.Rows.Count, 1).End(xlUp).FormulaR1C1 = "=SUM(R1C1:R[-1]C)"
End Sub