Ok, I've written a macro out to calculate the totals of columns from D
to the end of that sheet. I need the sum formula to fill to the right
from D + lastrow to the last column's last row.
Here's my code. (just ignore the msgbox thing- I'll take that out when
it works)
Sub totals()
Dim endcell
Dim lastrow
Dim lastcolumn
Set endcell = ActiveSheet.UsedRange
lastrow = endcell(endcell.Count).Row
lastcolumn = endcell(endcell.Count).column
Range("D" + CStr(lastrow + 1)).Select
ActiveCell.FormulaR1C1 = "=SUM(R2C:R" + CStr(lastrow) + "C)"
MsgBox CStr(lastcolumn)
Selection.AutoFill Destination:=Range("D" + CStr(lastrow + 1) + ":"
+ CStr(lastcolumn) + CStr(lastrow + 1)), Type:=xlFillDefault
End Sub
After hours of trying to debug, I realized that my count for lastcolumn
returns a number- I need a letter (my number right now is 49). I think
I've gotten everything else right, but any other things wrong with it
would be greatly appreciated. Anyways, how can I change my macro to
make it work? Thanks for your time.
Brett Smith
Bookmarks