Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro code to autosum a dynamic length column
I have a macro where I want to get some totals of a couple columns. I
have the row number in a variable where I will put the totals, but cannot figure out how to do the autosum. Here is the code I am trying to get working. nRow is the row for the totals. I want to total columns M and N from row 2 to nRow. I would appreciate some help in this. nRow = nRow + 2 Cells(nRow, 1) = "Totals" ' Range(nRow).Select ' ActiveCell.FormulaR1C1 = "Totals" Range("M2:M" & nRow).Select ' cells(nRow,13) ActiveCell.FormulaR1C1 = "=SUM(M2:M7,(IF(COUNT(M9:M990)0,OFFSET(M9,0,0,COU NT(M9:M990)),0)))" ' ActiveCell.FormulaR1C1 = "=SUM(M2:MR[-1]C)" ' Range("N2:N26").Select ' Range("N26").Activate ' ActiveCell.FormulaR1C1 = "=SUM(R[-24]C:R[-1]C)" |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro code to autosum a dynamic length column
How about
Cells(nRow,"M").Formula = "=SUM("M2:M" & nRow - 1 & ")" -- HTH Bob Phillips (remove nothere from email address if mailing direct) "SlowPoke" wrote in message ups.com... I have a macro where I want to get some totals of a couple columns. I have the row number in a variable where I will put the totals, but cannot figure out how to do the autosum. Here is the code I am trying to get working. nRow is the row for the totals. I want to total columns M and N from row 2 to nRow. I would appreciate some help in this. nRow = nRow + 2 Cells(nRow, 1) = "Totals" ' Range(nRow).Select ' ActiveCell.FormulaR1C1 = "Totals" Range("M2:M" & nRow).Select ' cells(nRow,13) ActiveCell.FormulaR1C1 = "=SUM(M2:M7,(IF(COUNT(M9:M990)0,OFFSET(M9,0,0,COU NT(M9:M990)),0)))" ' ActiveCell.FormulaR1C1 = "=SUM(M2:MR[-1]C)" ' Range("N2:N26").Select ' Range("N26").Activate ' ActiveCell.FormulaR1C1 = "=SUM(R[-24]C:R[-1]C)" |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro code to autosum a dynamic length column
It gives a compile error on compile pointing to M2 "Expected end of
statement" |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro code to autosum a dynamic length column
Sorry, my typo
Cells(nRow,"M").Formula = "=SUM(M2:M" & nRow - 1 & ")" -- HTH Bob Phillips (remove nothere from email address if mailing direct) "SlowPoke" wrote in message oups.com... It gives a compile error on compile pointing to M2 "Expected end of statement" |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Import a Code to a paragraph using a formula or macro! | Excel Worksheet Functions | |||
Return SEARCHED Column Number of Numeric Label and Value | Excel Worksheet Functions | |||
Closing File Error | Excel Discussion (Misc queries) | |||
Make Change Case in Excel a format rather than formula | Excel Worksheet Functions | |||
Zip Code Macro | Excel Worksheet Functions |