i honestly don't know anything about the TREND function, i'm just
looking at your code.

you haven't told VBA where to start........ such as,
you tell it to use these values
rg - 1, cg - 1
but you haven't told it where to start.
as in
rg = 5
cg = 3
rg-1, cg-1
then it would know to start in rg & cg, & subtract one from each of
them. and even though vba is not using those values except to put
into this function, you may have to qualify them.
a question - if you enter this formula directly into the worksheet,
does it work there????
=TREND(ThisWorkbook.Worksheets(""TableFigure"").Cells(rg -
1, cg - 1), _
ThisWorkbook.Worksheets(""TableFigure"").Cells(rg, cg), _
ThisWorkbook.Worksheets(""TableFigure"").Cells(rg - 1, cg), _
ThisWorkbook.Worksheets(""T-section"").Cells(r, c))
i don't know - maybe i'm way off. just trying to help.

susan
On Mar 30, 12:45 pm, Nasir.Mu...@dal.ca wrote:
> I am just trying to test, if I can use "TREND" function of excel in my
> vba code. TREND function takes range as parameter.
>
> Dim r As Integer
> Dim c As Integer
> Dim rg As Integer
> Dim cg As Integer
> Dim testing As Double
>
> testing = "=TREND(ThisWorkbook.Worksheets(""TableFigure"").Cells(rg -
> 1, cg - 1), _
>
> ThisWorkbook.Worksheets(""TableFigure"").Cells(rg, cg), _
>
> ThisWorkbook.Worksheets(""TableFigure"").Cells(rg - 1, cg), _
> ThisWorkbook.Worksheets(""T-
> section"").Cells(r, c))"
> Debug.Print testing