Cal_Lefty21
New Member
- Joined
- Jun 14, 2015
- Messages
- 6
I am trying to use the sum function in VBA to sum columns B, C, and D. the Data starts in B5 and I want the Sums to appear in B4, C4, D4. I am trying to use .end(xlDown) so if data is entered later the sum will pick up the newly entered information without having to change the range. This is what I have so far below but I am unable to get the Sum calculations to appear in B4, C4, D4
Sub calcSums()
Dim EndRow As Integer
Dim EndCol As Integer
Dim cell As Range
With Range("B5")
EndRow = .Offset(1, 0).End(xlDown).Row
EndCol = .Offset(0, 1).End(xlToRight).Column
For Each cell In Range(Cells(EndRow, .Offset(0, 1).Column), Cells(EndRow, EndCol))
cell.FormulaR1C1 = "=SUM(R[-109]C:R[-1]C)"
Next
End With
End Sub
Thanks!
Sub calcSums()
Dim EndRow As Integer
Dim EndCol As Integer
Dim cell As Range
With Range("B5")
EndRow = .Offset(1, 0).End(xlDown).Row
EndCol = .Offset(0, 1).End(xlToRight).Column
For Each cell In Range(Cells(EndRow, .Offset(0, 1).Column), Cells(EndRow, EndCol))
cell.FormulaR1C1 = "=SUM(R[-109]C:R[-1]C)"
Next
End With
End Sub
Thanks!
Last edited: