Link to home
Start Free TrialLog in
Avatar of Euro5
Euro5Flag for United States of America

asked on

Total columns vba not working

The last few lines of Sub FORMATREPORT() should total the last two columns on Report tab - Ground Rates & MWT Rates.
All I get is an error, but not sure why. Can anyone help?
test.xlsb
Avatar of Roy Cox
Roy Cox
Flag of United Kingdom of Great Britain and Northern Ireland image

Why not format the data as Table and add a Total Row. Most of the code is simply formatting so Format the Table as you want and the formatting will copy down as data is added
Excel TablesExcel Tables

This does not put a formula into the cell, just the result

Range("J" & LastRow) = WorksheetFunction.Sum(Range("J2:J" & LastRow - 1))LastRow = Cells(Cells.Rows.Count, "J").End(xlUp).Row + 1
Range("J" & LastRow) = WorksheetFunction.Sum(Range("J2:J" & LastRow - 1))

Open in new window


This puts a formula in

LastRow = Cells(Cells.Rows.Count, "J").End(xlUp).Row + 1
Range("J" & LastRow).FormulaR1C1= WorksheetFunction.Sum(Range("J2:J" & LastRow - 1))
"=SUM(R[-1582]C:R[-1]C)"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Euro5

ASKER

Thanks!!