Sorry for the torrent of questions today, I have lots and lots of things I'm learning at the moment!
I've created a simple macro to add an autosum to the bottom of a dynamic table. The table is created from other parts of the macro, and can vary in size.
I've created a variable that counts how many rows, but I'm stuck on adding it into creating the sum. This is what I've got so far
Dim rowsamount As Integer
Range("A2").Select
rowsamount = Range(Selection, Selection.End(xlDown)).Count
Range("B2").Select
ActiveCell.End(xlDown).Offset(2, 0).Select
Application.Sum (Range(-rowsamount, 0))
I also tried swapping the last line for ActiveCell.FormulaR1C1 = "=SUM(R[-rowsamount]C:R[-2]C) Based on recording an excel macro
How can I get it to sum correctly?
I've created a simple macro to add an autosum to the bottom of a dynamic table. The table is created from other parts of the macro, and can vary in size.
I've created a variable that counts how many rows, but I'm stuck on adding it into creating the sum. This is what I've got so far
Dim rowsamount As Integer
Range("A2").Select
rowsamount = Range(Selection, Selection.End(xlDown)).Count
Range("B2").Select
ActiveCell.End(xlDown).Offset(2, 0).Select
Application.Sum (Range(-rowsamount, 0))
I also tried swapping the last line for ActiveCell.FormulaR1C1 = "=SUM(R[-rowsamount]C:R[-2]C) Based on recording an excel macro
How can I get it to sum correctly?