View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default How to create a formula in VBA to assign to a cell

dim rng as Range
set rng = Range(cells(5,5),cells(5,5).End(xldown))
ActiveCell.Formula = "=Sum(" & rng.Address & ")"

where rng is a reference to the range you want summed



--
Regards,
Tom Ogilvy


"Rusty" wrote in message
.com...
Hi,

I'm trying to sum up some cells in a simple formula to assign to a
different cell. For example "=sum(E5:E33)"

However, do I create the above line of code without hard-coding the range?
I do not want to used named ranges as I have thousand of rows to sum up.

Your help is appreciated.

Rusty