Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Summing two columns


Hey all,

I have a worksheet which has two columns to it and I need a third t
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
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

--
Hru4
-----------------------------------------------------------------------
Hru48's Profile: http://www.excelforum.com/member.php...fo&userid=2489
View this thread: http://www.excelforum.com/showthread.php?threadid=50686

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Summing two columns

hi hru48

try this.

Sub CountSum()
Dim colE As Double
colE = Cells(Rows.Count, "E").End(xlUp).Row
Range("G3:g" & colE).FormulaR1C1 = "=SUM(RC[-2]:RC[-1])"
End Sub
regards yngve

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Summing two columns

iLastrow = Cells(Rows.Count,"E").End(xlUp).Row
Range("G3").FormulaR1C1 = "=RC[-2]+RC[-1]"
Range("G3").Autofill Range("G3").Resize(iLastrow)


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Hru48" wrote in
message ...

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=506867



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Summing two columns


Thanks alot for your help this is gran

--
Hru4
-----------------------------------------------------------------------
Hru48's Profile: http://www.excelforum.com/member.php...fo&userid=2489
View this thread: http://www.excelforum.com/showthread.php?threadid=50686

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
Summing across columns while skipping some columns JAG Excel Worksheet Functions 2 February 28th 10 02:58 PM
summing columns drakey Excel Worksheet Functions 5 January 13th 09 05:18 PM
Summing columns [email protected] Excel Discussion (Misc queries) 1 March 15th 07 03:27 PM
summing columns thedarkman Excel Worksheet Functions 1 January 2nd 06 07:42 PM
Not summing a columns? Nicole Excel Worksheet Functions 2 April 23rd 05 03:30 PM


All times are GMT +1. The time now is 03:46 AM.

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"