View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
[email protected] takuto.yamada@gmail.com is offline
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!