Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default VBA: Using a range in a formula

Is there a way to use a range that i've declared previously in the same macro?

In my example, row1 and row2 are the ranges I want to use
(work_items_database was not declared in the macro). I want to use these
ranges in a dsum formula to go from the position of row1 to the position of
row2, but this does not work:

Sheets("hours available").Cells(ActiveCell.Row + 1,
ActiveCell.Column).FormulaR1C1 = "=dsum(work_items_database,""work effort
(hours)""," & row1.Address & ":" & row2.Address & ")"

Again, row1 and row2 are ranges that I have already declared and assigned
locations to.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Using a range in a formula

Try

Sheets("hours available").Cells(ActiveCell.Row + 1,
ActiveCell.Column).Formula = "=dsum(work_items_database,""work effort
(hours)""," & row1.Address & ":" & row2.Address & ")"


--
__________________________________
HTH

Bob

"Jayne22" wrote in message
...
Is there a way to use a range that i've declared previously in the same
macro?

In my example, row1 and row2 are the ranges I want to use
(work_items_database was not declared in the macro). I want to use these
ranges in a dsum formula to go from the position of row1 to the position
of
row2, but this does not work:

Sheets("hours available").Cells(ActiveCell.Row + 1,
ActiveCell.Column).FormulaR1C1 = "=dsum(work_items_database,""work effort
(hours)""," & row1.Address & ":" & row2.Address & ")"

Again, row1 and row2 are ranges that I have already declared and assigned
locations to.



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 do I enter formula sum(range+range)*0.15 sumif(range=3) tkw Excel Discussion (Misc queries) 2 October 1st 09 09:17 PM
conditional formula: sum a range if text present in another range NeedAdvice777 Excel Discussion (Misc queries) 10 August 29th 06 04:51 PM
formula to sort a range so that it matches the exact rows of a column that is outside that range? steveo Excel Discussion (Misc queries) 1 June 18th 06 02:05 AM
Macro to input formula in range based on another range Peter Atherton Excel Programming 0 October 9th 03 12:47 AM
Range.Formula and Range question using Excel Automation [email protected] Excel Programming 0 September 19th 03 04:53 AM


All times are GMT +1. The time now is 02:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"