Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default variables in formulas

I'm trying to put in formulas for a row of cells. The row location is
a variable. The formula is an average of a variable number of rows
above it. So, there are variables within the formula. After setting
the formula for the first column, I just want to fill right with that
formula, so the appropriate column is filled.

The problem is that this command does not seem to put cell references
for StartCell and EndCell.

Dim RL, C, R, RLAST As Integer
Dim StartCell As Range
Dim EndCell As Range


ActiveSheet.Range("c" & R).Formula =
"=if(ISERROR(AVERAGE(StartCell,EndCell)),"""",AVER AGE(StartCell,EndCell))"


Also tried using
ActiveSheet.Range("C" & R).FormulaR1C1
but couldn't figure out if that it really the way to go.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default variables in formulas

ActiveSheet.Range("c" & R).Formula = _
"=if(ISERROR(AVERAGE(" & _
StartCell.Address & ":" & EndCell.Address & ")),"""",AVERAGE(" & _
StartCell.Address & ":" & EndCell.Address & "))"


--
Regards,
Tom Ogilvy


wrote in message
ups.com...
I'm trying to put in formulas for a row of cells. The row location is
a variable. The formula is an average of a variable number of rows
above it. So, there are variables within the formula. After setting
the formula for the first column, I just want to fill right with that
formula, so the appropriate column is filled.

The problem is that this command does not seem to put cell references
for StartCell and EndCell.

Dim RL, C, R, RLAST As Integer
Dim StartCell As Range
Dim EndCell As Range


ActiveSheet.Range("c" & R).Formula =
"=if(ISERROR(AVERAGE(StartCell,EndCell)),"""",AVER AGE(StartCell,EndCell))"


Also tried using
ActiveSheet.Range("C" & R).FormulaR1C1
but couldn't figure out if that it really the way to go.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default variables in formulas

On Feb 14, 8:35 pm, "Tom Ogilvy" wrote:
ActiveSheet.Range("c" & R).Formula = _
"=if(ISERROR(AVERAGE(" & _
StartCell.Address & ":" & EndCell.Address & ")),"""",AVERAGE(" & _
StartCell.Address & ":" & EndCell.Address & "))"

--
Regards,
Tom Ogilvy

wrote in message

ups.com...

I'm trying to put in formulas for a row of cells. The row location is
a variable. The formula is an average of a variable number of rows
above it. So, there are variables within the formula. After setting
the formula for the first column, I just want to fill right with that
formula, so the appropriate column is filled.


The problem is that this command does not seem to put cell references
for StartCell and EndCell.


Dim RL, C, R, RLAST As Integer
Dim StartCell As Range
Dim EndCell As Range


ActiveSheet.Range("c" & R).Formula =
"=if(ISERROR(AVERAGE(StartCell,EndCell)),"""",AVER AGE(StartCell,EndCell))"


Also tried using
ActiveSheet.Range("C" & R).FormulaR1C1
but couldn't figure out if that it really the way to go.


Thank you so much Tom!

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
Temp variables within formulas? Andy Smith[_2_] Excel Discussion (Misc queries) 2 May 7th 09 05:39 PM
Variables in formulas build Excel Worksheet Functions 9 October 11th 07 12:35 PM
What if < with multiple variables and formulas Anna Excel Discussion (Misc queries) 3 July 18th 07 03:54 PM
Integrating variables in formulas in VB??? thorsten Excel Programming 2 May 16th 06 08:42 PM
How can I use variables in formulas in VB? thorsten Excel Discussion (Misc queries) 2 May 16th 06 08:22 PM


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