Summing two columns

  • Thread starter Thread starter Hru48
  • Start date Start date
H

Hru48

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
 
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
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Linking Cells Macro 3
Referring to a column 1
Dynamic add formula 2
Compile Error - Procedure too large 7
Help with my VBA and formula 8
Totals An Easier Way?? 5
Data samples 3
Geometric progression in VBA 10

Back
Top