OzGrid

How to use VBA to SUM result in last Row in columns (A:A)

< Back to Search results

 Category: [Excel]  Demo Available 

How to use VBA to SUM result in last Row in columns (A:A)

 

Requirement:

 

The user would like to edit code to SUM result in last row in columns A:A.

 

The user is currently using the following code:

Worksheets("sheet1").Columns("A:A").Select
Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=SUM(A:A" & LastRow & ")"
End

 

https://www.ozgrid.com/forum/forum/help-forums/excel-vba-macros/1203207-vba-how-to-sum-result-in-last-row-in-columns-a-a

 

Solution:

 

Code:
Sub Sum_Last_Row()

Dim LastRow As Long

LastRow = Cells(Rows.Count, "A").End(xlUp).Row

Range("A" & LastRow + 1 & ":F" & LastRow + 1).Formula = "=SUM(A2:A" & LastRow & ")"

End Sub

 

Obtained from the OzGrid Help Forum.

Solution provided by chirayuw.

 

See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets

See also:

How to merge duplicate rows and sum value
How to use SUMIFS and include 'All' to Drop-down IndexMatch
How to sum cell numerical values based on text suffix
How to use SUMPRODUCT and COUNT question for unique associations

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.


Gallery



stars (0 Reviews)