close

Hey all,

I have a worksheet which has two columns to it and I need a third to
act as a totals column for all the values in columns a and b.

I'm doing it as part of a sub in vba and I need to know if there is a
short way of reffering to column as I keep ending up with pages of:

Range(quot;G3quot;).Activate
ActiveCell.FormulaR1C1 = quot;=SUM(RC[-2]:RC[-1])quot;
Columns(quot;E:Gquot;).Select
Range(quot;G4quot;).Activate
ActiveCell.FormulaR1C1 = quot;=SUM(RC[-2]:RC[-1])quot;
Columns(quot;E:Gquot;).Select
Range(quot;G5quot;).Activate
ActiveCell.FormulaR1C1 = quot;=SUM(RC[-2]:RC[-1])quot;

Many thanks,--
Hru48
------------------------------------------------------------------------
Hru48's Profile: www.excelforum.com/member.php...oamp;userid=24895
View this thread: www.excelforum.com/showthread...hreadid=506856Use these two snippets in your code. The dim statement comes after Sub.
The for...next statement goes wherever necessary. Modify
range(quot;G2:G100quot;) as necessary.

dim c as range

for each c in range(quot;G2:G1000quot;).cells
c.formular1c1=quot;=SUM(RC[-2]:RC[-1])quot;
next c

HTH
Kostis Vezerides

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

    software

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