Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Getting output from the TREND function using VBA

The TREND function has the syntax TREND(known_y's,known_x's,new_x's,const).
In order to output the array of estimated y values on a spreadsheet, the
Excel Help entry specifies that a range must be selected beginning with the
cell in which the TREND function is entered and extending downward so that
the number of cells in the range is equal to the number of estimated y
values. The user is then instructed to press F2, and then press
CTRL+SHIFT+ENTER, causing the estimated y values to populate the selected
range. That method works fine for outputting the estimated y values on a
spreadsheet, but how do I output the estimated y values as an array within a
VBA subprogram?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Getting output from the TREND function using VBA

arrNewY = Application.WorksheetFunction.Trend(knownY, knownX, newXs, const)

knownY, knownX and newXs can refer to cells or arrays made in VBA

arrNewY is an array, even if newXs is a single value, with lower-bound of 1
and qty of elements same as newXs

Regards,
Peter T

"stanleykorn" wrote in message
...
The TREND function has the syntax
TREND(known_y's,known_x's,new_x's,const).
In order to output the array of estimated y values on a spreadsheet, the
Excel Help entry specifies that a range must be selected beginning with
the
cell in which the TREND function is entered and extending downward so that
the number of cells in the range is equal to the number of estimated y
values. The user is then instructed to press F2, and then press
CTRL+SHIFT+ENTER, causing the estimated y values to populate the selected
range. That method works fine for outputting the estimated y values on a
spreadsheet, but how do I output the estimated y values as an array within
a
VBA subprogram?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Getting output from the TREND function using VBA

Peter,

I tried using that method. I entered the following statements in the
subprogram:

Dim ArrNewY(2 To 12) As Single
ArrNewY = Application.WorksheetFunction.Trend(E2:E12,A2:D12)

After entering the second statement, I got the following compile error:

Expected: list separator or )

with the colon between the E2 and E12 highlighted.

The same input to the TREND function worked perfectly fine when I used the
TREND function directly on the worksheet.

"Peter T" wrote:

arrNewY = Application.WorksheetFunction.Trend(knownY, knownX, newXs, const)

knownY, knownX and newXs can refer to cells or arrays made in VBA

arrNewY is an array, even if newXs is a single value, with lower-bound of 1
and qty of elements same as newXs

Regards,
Peter T

"stanleykorn" wrote in message
...
The TREND function has the syntax
TREND(known_y's,known_x's,new_x's,const).
In order to output the array of estimated y values on a spreadsheet, the
Excel Help entry specifies that a range must be selected beginning with
the
cell in which the TREND function is entered and extending downward so that
the number of cells in the range is equal to the number of estimated y
values. The user is then instructed to press F2, and then press
CTRL+SHIFT+ENTER, causing the estimated y values to populate the selected
range. That method works fine for outputting the estimated y values on a
spreadsheet, but how do I output the estimated y values as an array within
a
VBA subprogram?



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Getting output from the TREND function using VBA

change this
Dim ArrNewY(2 To 12) As Single
ArrNewY = Application.WorksheetFunction.Trend(E2:E12,A2:D12)

to

Dim ArrNewY as Variant ' it will become an array later
dim rngX as range, rngY as range
Dim newXs ' as Range or As Variant

Set rngX = actrivesheet.range("A2:D12")
Set rngY = actrivesheet.range("E2:E12")
Set newXs = some-range
or
newXs = array(1.5, 3.5,.....)

ArrNewY = Application.WorksheetFunction.Trend(rngY,rngX,newX s )

if the const is ommited the default is True

Regards,
Peter T

"stanleykorn" wrote in message
...
Peter,

I tried using that method. I entered the following statements in the
subprogram:

Dim ArrNewY(2 To 12) As Single
ArrNewY = Application.WorksheetFunction.Trend(E2:E12,A2:D12)

After entering the second statement, I got the following compile error:

Expected: list separator or )

with the colon between the E2 and E12 highlighted.

The same input to the TREND function worked perfectly fine when I used the
TREND function directly on the worksheet.

"Peter T" wrote:

arrNewY = Application.WorksheetFunction.Trend(knownY, knownX, newXs,
const)

knownY, knownX and newXs can refer to cells or arrays made in VBA

arrNewY is an array, even if newXs is a single value, with lower-bound of
1
and qty of elements same as newXs

Regards,
Peter T

"stanleykorn" wrote in message
...
The TREND function has the syntax
TREND(known_y's,known_x's,new_x's,const).
In order to output the array of estimated y values on a spreadsheet,
the
Excel Help entry specifies that a range must be selected beginning with
the
cell in which the TREND function is entered and extending downward so
that
the number of cells in the range is equal to the number of estimated y
values. The user is then instructed to press F2, and then press
CTRL+SHIFT+ENTER, causing the estimated y values to populate the
selected
range. That method works fine for outputting the estimated y values on
a
spreadsheet, but how do I output the estimated y values as an array
within
a
VBA subprogram?



.



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
Trend Function Grant Excel Worksheet Functions 3 September 12th 06 04:12 PM
constraints for the trend function name Excel Discussion (Misc queries) 0 July 3rd 06 03:02 AM
Help with TREND function systemx Excel Worksheet Functions 0 March 24th 06 09:43 AM
Trend function question [email protected] Excel Discussion (Misc queries) 2 February 15th 06 11:15 PM
Trend function in VB Pierre Laporte Excel Programming 0 July 10th 03 08:22 PM


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