#1
|
|||
|
|||
Summation where range vary using Macro
Hi,
How do I improve this code by getting the summation of the same column with varying rows? Here is the code I use. Code:
Sub sum() ' ' sum Macro ' ActiveCell.FormulaR1C1 = "=SUM(R[-48]C:R[-1]C)" With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With End Sub Thanks, Last edited by halogen_bulb; 11-15-2011 at 07:53 AM. |
#2
|
||||
|
||||
Last edited by Pecoflyer; 11-15-2011 at 06:03 AM. |
#3
|
|||
|
|||
Solution I gathered form this forum and other forums
Code:
Sub sumx() Dim LastRow As Long LastRow = Range("P65536").End(xlUp).Row + 1 ActiveCell.Select Selection.Formula = "=SUM(P" & LastRow + 1 & ":" & Format(ActiveCell.Row - 1, "P#") & ")" End Sub Last edited by halogen_bulb; 11-15-2011 at 07:37 AM. Reason: [SOLVED] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Print Macro w/ Page Range? | stickyit | Outlook | 1 | 10-06-2011 09:51 AM |
Work Week: hours vary each day | rkc | Outlook | 1 | 08-31-2011 01:17 PM |
Generic range for custom sort macro? | tswiers | Excel Programming | 2 | 08-11-2011 02:40 AM |
use VBA to name a range | g48dd | Excel Programming | 7 | 06-20-2011 06:34 AM |
Sort Range | boutells | Excel | 1 | 07-15-2009 03:02 AM |