I am having trouble writing the code so that a loop will add the cells in a row and place the sum on the first open cell on the right. I need it to be in a loop and also work with any amount and size of other rows. I have the code to work so that it will place the column cells at the bottom but I am unable to figure out how to just add the cells in the row.
Here is the code that I have so far
Here is the code that I have so far
Code:
Option Explicit
Sub RowsGetStats()
Dim LastRow As Long, LastColumn As Long, lngRow As Long
LastRow = Cells.Find(What:="*", After:=Range("A1"), _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
For lngRow = 1 To LastRow
LastColumn = Cells(lngRow, Columns.Count).End(xlLeft).Column
With Cells(lngRow, LastColumn + 1)
.FormulaR1C1 = "=SUM(R" & LastRow & "C:RC2)"
End With
Next lngRow
End Sub
Last edited by a moderator: