PDA

View Full Version : Add current value to running total



GribbiN
12-22-2015, 04:58 AM
Good Morning,

Due to my lack of VBA knowledge i currently have a complicated way of adding the value of one column to a running total in another.

I currently have hidden columns which add the total and input value together, then the hidden columns are copied and pasted to replace the total then the input value cleared for the next cycle.

Although my method and recorded macro works fine there are other items we log throughout the year so would like to simplify the code and sheets. As there is a lot more manual work my way

With a working macro i would delete all hidden columns so the code would be for this

D Input/E Total
F Input/G Total
H Input/I Total
J Inout/K Total

Not all input cells will have values each day

As with all the help i have received in the past thanks in advance and Happy Holidays

John

15018

Aflatoon
12-22-2015, 05:34 AM
A sample workbook would be simpler. I can't really see why simple SUM formulas won't do what you describe currently.

GribbiN
12-22-2015, 11:43 AM
Attached.

Thanks for looking

15023

Aflatoon
12-23-2015, 01:50 AM
Delete all the hidden columns and then change the code to:

Sub Macro1()

'ActiveSheet.Unprotect "audit1"
Application.ScreenUpdating = False
Range("D4:D43").Copy
Range("E4").PasteSpecial Paste:=xlPasteValues, Operation:=xlAdd
Range("F4:F43").Copy
Range("G4").PasteSpecial Paste:=xlPasteValues, Operation:=xlAdd
Range("H4:H43").Copy
Range("I4").PasteSpecial Paste:=xlPasteValues, Operation:=xlAdd
Range("J4:J43").Copy
Range("K4").PasteSpecial Paste:=xlPasteValues, Operation:=xlAdd
Range("D4:D43,F4:F43,H4:H43,J4:J43").ClearContents
Range("D4").Select
Application.ScreenUpdating = True
'ActiveSheet.Protect "audit1"

End Sub