View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default entering formulas on a sheet

sub SetupSums()
Dim rng as Range
for i = 1 to 10
set rng = cells(rows.count,i).End(xlup)(2)
rng.FormulaR1C1 = "=Sum(R3C:R[-1]C)"
Next
End Sub

change 10 to the number of columns to process.


"stu" wrote in message
s.com...
Hi

I have a sheet which is created from a search of a much larger sheet. the
number of rows can vary from 1 to XXX. I would like to do a sum of the
columns and have it placed on the next empty row. I have tried using the
.formula = "=sum(c3:C"+variable+")" in a loop but just get mismatch

errors.
any help would be gratefully appreciated.

Regards

Stu