How to SUM Totals At Bottom of Columns Dynamically

  • Hi
    I am a not that much familiar with macro.


    I have a sheet containing columns from A to P
    The row are never the same lenght


    I want the total of each column from E3 to N3 going down to the last data entry


    And in Column A in the row I Want to write Total


    Thank you

  • Re: How to SUM Totals At Bottom of Columns Dynamically


    Try this. :cool:

    Code
    Sub TotalRow()
    Dim c As Long, lr As Long
        With Worksheets("Sheet1")
            lr = .Cells(.Rows.Count, 1).End(xlUp).Row
            .Cells(lr + 1, 1).Value = "Total"
            For c = 5 To 13
                .Cells(lr + 1, c).Formula = "=SUM(" & .Range(.Cells(3, c), .Cells(lr, c)).Address & ")"
            Next c
        End With
    End Sub

    Bruce :cool:

  • Re: How to SUM Totals At Bottom of Columns Dynamically


    Try this. :cool:

    Bruce :cool:

  • Re: How to SUM Totals At Bottom of Columns Dynamically


    Just FWIW, you can avoid looping:

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!