Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Ron DeBruin Macro - Moving Sheet Name from Last Column to Column A | Excel Worksheet Functions | |||
Macro - Insert&Label Column, if the labeled column doesn't exist | Excel Programming | |||
Need Macro to Find Column Heading -- if none, then insert new column | Excel Programming | |||
macro to transpose cells in Column B based on unique values in Column A | Excel Programming | |||
macro to delete entire rows when column A is blank ...a quick macro | Excel Programming |