Consulting

Results 1 to 4 of 4

Thread: Add current value to running total

  1. #1
    VBAX Regular
    Joined
    May 2015
    Posts
    34
    Location

    Add current value to running total

    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

    Totals.JPG

  2. #2
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    A sample workbook would be simpler. I can't really see why simple SUM formulas won't do what you describe currently.
    Be as you wish to seem

  3. #3
    VBAX Regular
    Joined
    May 2015
    Posts
    34
    Location
    Attached.

    Thanks for looking

    VBA Express.xlsm

  4. #4
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    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
    Be as you wish to seem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •