Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Hru48
 
Posts: n/a
Default Referring to a column


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("G3").Activate
ActiveCell.FormulaR1C1 = "=SUM(RC[-2]:RC[-1])"
Columns("E:G").Select
Range("G4").Activate
ActiveCell.FormulaR1C1 = "=SUM(RC[-2]:RC[-1])"
Columns("E:G").Select
Range("G5").Activate
ActiveCell.FormulaR1C1 = "=SUM(RC[-2]:RC[-1])"

Many thanks,


--
Hru48
------------------------------------------------------------------------
Hru48's Profile: http://www.excelforum.com/member.php...o&userid=24895
View this thread: http://www.excelforum.com/showthread...hreadid=506856

  #2   Report Post  
Posted to microsoft.public.excel.misc
vezerid
 
Posts: n/a
Default Referring to a column

Use these two snippets in your code. The dim statement comes after Sub.
The for...next statement goes wherever necessary. Modify
range("G2:G100") as necessary.

dim c as range

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

HTH
Kostis Vezerides

Reply
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
Return SEARCHED Column Number of Numeric Label and Value Sam via OfficeKB.com Excel Worksheet Functions 23 January 30th 06 06:16 PM
IF/AND/OR/DATEIF Issue...sorry...long post... EDSTAFF Excel Worksheet Functions 1 November 10th 05 12:28 AM
creating a bar graph Johnfli Excel Discussion (Misc queries) 0 October 26th 05 08:16 PM
How to group similar column titles together???? vrk1 Excel Discussion (Misc queries) 2 April 30th 05 12:17 AM
Return Count for LAST NonBlank Cell in each Row Sam via OfficeKB.com Excel Worksheet Functions 12 April 17th 05 10:36 PM


All times are GMT +1. The time now is 01:37 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"