waltdakind
New Member
- Joined
- May 11, 2010
- Messages
- 30
Hi All,
I hope that I'm just missing something simple here -- I can't get the following code to work.
It's supposed to loop through the range and populate the cells in the range with the sum of the range varying on the size of the grid. I tried adding the "Address" property to cells, but that didn't work either. What am I missing?
Thanks for whatever help you can give!
I hope that I'm just missing something simple here -- I can't get the following code to work.
Code:
Sub sumfornondddgrid()
Dim lastrow As Integer
Dim lastcolumn As Integer
Sheets("02Grid by Dept and GLCode").Activate
lastrow = Cells(Rows.Count, "B").End(xlUp).Row
lastcolumn = Cells(1, Columns.Count).End(xlToLeft).Column
For i = lastrow To 3 Step -1
Range(Cells(i, lastcolumn)).Offset(0,1).Formula="=SUM(" & Cells(i, 4), Cells(i, lastcolumn)) & ")"
Next i
End Sub
It's supposed to loop through the range and populate the cells in the range with the sum of the range varying on the size of the grid. I tried adding the "Address" property to cells, but that didn't work either. What am I missing?
Thanks for whatever help you can give!