close

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) = quot;Totalsquot;
' Range(nRow).Select
' ActiveCell.FormulaR1C1 = quot;Totalsquot;
Range(quot;M2:Mquot; amp; nRow).Select
' cells(nRow,13)
ActiveCell.FormulaR1C1 =
quot;=SUM(M2:M7,(IF(COUNT(M9:M990)gt;0,OFFSET(M9,0,0,COU NT(M9:M990)),0)))quot;

' ActiveCell.FormulaR1C1 = quot;=SUM(M2:MR[-1]C)quot;
' Range(quot;N2:N26quot;).Select
' Range(quot;N26quot;).Activate
' ActiveCell.FormulaR1C1 = quot;=SUM(R[-24]C:R[-1]C)quot;How about

Cells(nRow,quot;Mquot;).Formula = quot;=SUM(quot;M2:Mquot; amp; nRow - 1 amp; quot;)quot;

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

quot;SlowPokequot; gt; wrote in message ups.com...
gt; I have a macro where I want to get some totals of a couple columns. I
gt; have the row number in a variable where I will put the totals, but
gt; cannot figure out how to do the autosum. Here is the code I am trying
gt; to get working. nRow is the row for the totals. I want to total
gt; columns M and N from row 2 to nRow. I would appreciate some help in
gt; this.
gt;
gt; nRow = nRow 2
gt; Cells(nRow, 1) = quot;Totalsquot;
gt; ' Range(nRow).Select
gt; ' ActiveCell.FormulaR1C1 = quot;Totalsquot;
gt; Range(quot;M2:Mquot; amp; nRow).Select
gt; ' cells(nRow,13)
gt; ActiveCell.FormulaR1C1 =
gt; quot;=SUM(M2:M7,(IF(COUNT(M9:M990)gt;0,OFFSET(M9,0,0,COU NT(M9:M990)),0)))quot;
gt;
gt; ' ActiveCell.FormulaR1C1 = quot;=SUM(M2:MR[-1]C)quot;
gt; ' Range(quot;N2:N26quot;).Select
gt; ' Range(quot;N26quot;).Activate
gt; ' ActiveCell.FormulaR1C1 = quot;=SUM(R[-24]C:R[-1]C)quot;
gt;
It gives a compile error on compile pointing to M2 quot;Expected end of
statementquot;Sorry, my typo

Cells(nRow,quot;Mquot;).Formula = quot;=SUM(M2:Mquot; amp; nRow - 1 amp; quot;)quot;

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

quot;SlowPokequot; gt; wrote in message oups.com...
gt; It gives a compile error on compile pointing to M2 quot;Expected end of
gt; statementquot;
gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()