Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excluding cells in custom TREND function

I'm trying to create a user defined function for a polynominal
regression that allows specified data to be excluded from the
calculation.
The following code works fine where there's only one "daynum" X-array
(i.e.
the trend is a straight-line). How should it be modified to cope
with two X-arrays (i.e. X and X^2) to produce a curvefit?
TIA....

Function XTREND(Array_daynum, Array_devs, ArrayIgnore)
Dim new_array_daynum(), new_array_devs()

arrayx = Range("Array_daynum").Value
arrayy = Range("Array_devs").Value
arrayc = Range("ArrayIgnore").Value

For L = 1 To UBound(arrayx)
c = arrayc(L, 1)
If c = 0 Then
x = arrayx(L, 1)
y = arrayy(L, 1)
j = j + 1
ReDim Preserve new_array_daynum(1 To j)
new_array_daynum(j) = x
ReDim Preserve new_array_devs(1 To j)
new_array_devs(j) = y
End If
Next L

With Application.WorksheetFunction
XTREND = .Trend(new_array_devs, new_array_daynum, Array_daynum)
End With
End Function
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Excluding cells in custom TREND function

As far as using polynomials with LINEST in VBA see my posts in
http://groups-
beta.google.com/group/microsoft.public.excel.charting/browse_thread/thr
ead/bd158645bcad9995

and

http://groups-
beta.google.com/group/microsoft.public.excel/browse_thread/thread/9130f
e9e85f1c476

As noted above, the posts deal with LINEST. Hopefully, the same works
for TREND. If not, use LINEST to get the coefficients, and create the
TREND results with a loop.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
I'm trying to create a user defined function for a polynominal
regression that allows specified data to be excluded from the
calculation.
The following code works fine where there's only one "daynum" X-array
(i.e.
the trend is a straight-line). How should it be modified to cope
with two X-arrays (i.e. X and X^2) to produce a curvefit?
TIA....

Function XTREND(Array_daynum, Array_devs, ArrayIgnore)
Dim new_array_daynum(), new_array_devs()

arrayx = Range("Array_daynum").Value
arrayy = Range("Array_devs").Value
arrayc = Range("ArrayIgnore").Value

For L = 1 To UBound(arrayx)
c = arrayc(L, 1)
If c = 0 Then
x = arrayx(L, 1)
y = arrayy(L, 1)
j = j + 1
ReDim Preserve new_array_daynum(1 To j)
new_array_daynum(j) = x
ReDim Preserve new_array_devs(1 To j)
new_array_devs(j) = y
End If
Next L

With Application.WorksheetFunction
XTREND = .Trend(new_array_devs, new_array_daynum, Array_daynum)
End With
End Function

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Excluding cells in custom TREND function

Thanks for the pointers, Tushar, most helpful.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Excluding cells in custom TREND function

In article .com,
says...
Thanks for the pointers, Tushar, most helpful.


You are welcome.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
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 excluding errors or "" Werner Rohrmoser Excel Worksheet Functions 0 November 21st 06 02:40 PM
Use TREND function with nonadjacent cells BonesCCS Excel Worksheet Functions 0 August 4th 05 10:59 PM
Custom Function not being auto calculated when cells change..help? Alex Wolff Excel Worksheet Functions 4 March 22nd 05 07:06 PM
Custom function to return output in multiple cells Asif[_3_] Excel Programming 1 December 2nd 03 06:22 PM
Excel custom plots and custom trend lines Mark Brantana Excel Programming 0 November 10th 03 06:48 AM


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