LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Last Column Macro

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ron DeBruin Macro - Moving Sheet Name from Last Column to Column A ScottMSP Excel Worksheet Functions 7 December 12th 08 06:07 PM
Macro - Insert&Label Column, if the labeled column doesn't exist Jeff[_43_] Excel Programming 1 December 15th 04 09:33 PM
Need Macro to Find Column Heading -- if none, then insert new column Jeff[_43_] Excel Programming 0 December 15th 04 07:08 AM
macro to transpose cells in Column B based on unique values in Column A Aaron J. Excel Programming 3 October 8th 04 02:29 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM


All times are GMT +1. The time now is 04:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"