Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to create a formula in VBA to assign to a cell

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to create a formula in VBA to assign to a cell

Thanks Tom. That really helped :)

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
How can I assign a value to a cell without putting a formula in it WFariss Excel Worksheet Functions 4 February 17th 10 01:10 PM
Formula - assign a cell to show the next ash3154 Excel Worksheet Functions 6 February 7th 09 10:08 AM
assign formula to another cell Dannycol Excel Worksheet Functions 3 May 12th 06 09:46 PM
Change cell formula & assign to VBA variable... Kevin Lyons Excel Programming 0 February 5th 05 06:58 AM
Create a formula into a String then assign string to a cell Myrna Larson[_2_] Excel Programming 6 August 23rd 03 09:42 PM


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