LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Inserting formulas depending on a variable

Use the Address of the range you want in the function:

Sub rangedemo()
Dim r As Range
Set r = Range("A2:D4")
Range("A1").Formula = "=SUM(" & r.Address & ")"
End Sub

--
Gary''s Student - gsnu200825


"Alexander" wrote:

It is possible to insert a formula in the cell by Formula property, for
instance:
Range("A1") Formula = "=Sum(A2:A12)"
How can I to change cells which are used in formula, depending on a
variable. For instance, I need to change the range A2:A12 to Ax:Ay depending
on variable - rng=Range("Ax:Ay") ?
I am using Excel2003.

 
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 do I add a variable range of columns depending on criteria Nedgingbelle Excel Worksheet Functions 0 November 25th 09 04:18 PM
Please help - subtotal using vlookup depending on variable month robstton Excel Discussion (Misc queries) 2 February 5th 09 12:27 AM
How do I sort between worksheets depending on variable Miriaham Excel Worksheet Functions 1 September 30th 08 11:34 PM
Inserting a Date depending on a spereate Cell Value Rob Excel Discussion (Misc queries) 1 November 28th 06 04:08 PM
Inserting # of rows depending on value in Column Christel Excel Programming 5 November 7th 03 07:57 PM


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