Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Trend funtion

Ok

I have data like this:

A B A B A B A B
1 10 2 20 3 30 4 ?

The trend formula is =trend (known y, [known x],new x)

Generally we select the known y values which are in continuous cells, and
then select known x values, after which for a new x value €“ y-values could be
estimated.

But is there any way that this could be done by selecting y and x €“ values
which are in non-contiguous cells( like values if present in alternative
cells)

Is there a way to program:
1.Collect all the values present in alternate cells starting from say A2 (
these are my y-values)
2. Next collect all the values present in alternate cells starting from say
A3 (these will be x values)
3. Now can I use the trend function for forecasting??

Is this a way possible..

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Trend funtion

Hi,

Try this:

Sub GetTrendData()

Dim xRng As Range, yRng As Range
Dim lastrow As Long, i As Long

lastrow = Cells(Rows.Count, "A").End(xlUp).Row

Set yRng = Cells(2, "A")
Set xRng = Cells(3, "A")

For i = 4 To lastrow Step 2
yRng = Union(yRng, Cells(i, "a"))
xRng = Union(xRng, Cells(i + 1, "a"))
Next i

Range("c1") = Application.Trend(yRng, xRng)

End Sub

HTH

"vijaya" wrote:

Ok

I have data like this:

A B A B A B A B
1 10 2 20 3 30 4 ?

The trend formula is =trend (known y, [known x],new x)

Generally we select the known y values which are in continuous cells, and
then select known x values, after which for a new x value €“ y-values could be
estimated.

But is there any way that this could be done by selecting y and x €“ values
which are in non-contiguous cells( like values if present in alternative
cells)

Is there a way to program:
1.Collect all the values present in alternate cells starting from say A2 (
these are my y-values)
2. Next collect all the values present in alternate cells starting from say
A3 (these will be x values)
3. Now can I use the trend function for forecasting??

Is this a way possible..

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Trend funtion

Your only taking the trend for A2 (y-val) and A3 (x-val)

if you use Set with the Union function as intended, then you get a #Ref for
the answer:

Maybe you wanted to build arrays like this:

Sub GetTrendData()
Dim lastrow As Long, i As Long
Dim ub As Long, j As Long
Dim yRng(), xRng()
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
ub = (lastrow - 1) / 2 - 1
Debug.Print ub
ReDim yRng(0 To ub)
ReDim xRng(0 To ub)
j = 0
For i = 2 To lastrow Step 2
yRng(j) = Cells(i, "a")
xRng(j) = Cells(i + 1, "a")
j = j + 1
Next i
For i = LBound(yRng) To UBound(yRng)
Next
Range("c1") = Application.Trend(yRng, xRng)

End Sub

--
Regards,
Tom Ogilvy


"Toppers" wrote in message
...
Hi,

Try this:

Sub GetTrendData()

Dim xRng As Range, yRng As Range
Dim lastrow As Long, i As Long

lastrow = Cells(Rows.Count, "A").End(xlUp).Row

Set yRng = Cells(2, "A")
Set xRng = Cells(3, "A")

For i = 4 To lastrow Step 2
yRng = Union(yRng, Cells(i, "a"))
xRng = Union(xRng, Cells(i + 1, "a"))
Next i

Range("c1") = Application.Trend(yRng, xRng)

End Sub

HTH

"vijaya" wrote:

Ok

I have data like this:

A B A B A B A B
1 10 2 20 3 30 4 ?

The trend formula is =trend (known y, [known x],new x)

Generally we select the known y values which are in continuous cells,

and
then select known x values, after which for a new x value - y-values

could be
estimated.

But is there any way that this could be done by selecting y and x -

values
which are in non-contiguous cells( like values if present in alternative
cells)

Is there a way to program:
1.Collect all the values present in alternate cells starting from say A2

(
these are my y-values)
2. Next collect all the values present in alternate cells starting from

say
A3 (these will be x values)
3. Now can I use the trend function for forecasting??

Is this a way possible..



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
What funtion to use? fetzer New Users to Excel 2 November 3rd 09 02:55 PM
funtion writing muzz46 Excel Discussion (Misc queries) 1 December 16th 08 08:38 AM
If Funtion David Excel Worksheet Functions 4 November 29th 05 08:09 PM
If funtion help fetzer New Users to Excel 5 July 3rd 05 07:02 PM
IF funtion viddom Excel Discussion (Misc queries) 2 June 30th 05 02:53 PM


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