Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default WorksheetFunction.Trend doesn't work?

Folks,

I can't seem to get this simple function to work

I keep getting an "Unable to get Trend Properties of the Worksheet Function
Class" error. Trend is on the supported Application.WorksheetFunction list.
Perhaps the Trend function is not supported by VBA - or am I just making a
foolish code error?

Below is the Code. On the active sheet, the range J11:U11 contains product
sales numbers between 5.05 and 9.30 (in thousands) and range J4:U4 contains
the numbers 1 to 12.

Thanks for your help.

Allan P. London, CPA

__________________________________________________ _
Sub FunctionTest()
MsgBox TF(11, 13)
End Sub
__________________________________________________ _
Function TF(theRow As Integer, theCol As Integer) As Double

Dim I As Integer
Dim theRange As String
Dim YRange As Range
Dim XRange As Range

theRange = "J" & theRow & ":U" & theRow
MsgBox (theRow & " " & theCol & " " & theRange)
Set YRange = ActiveSheet.Range(theRange)
Set XRange = ActiveSheet.Range("J4:U4")
TF = Application.WorksheetFunction.Trend(YRange, XRange, theCol)

End Function


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default WorksheetFunction.Trend doesn't work?

Sub FunctionTest()
Dim i As Integer
Dim v As Variant
Dim v1 As Variant
ReDim v(1 To 1)
v(1) = 13
i = 11
v1 = TF(i, v)
For i = LBound(v1) To UBound(v1)
Debug.Print i, v1(i)
Next
End Sub

Function TF(theRow As Integer, theCol As Variant)

Dim i As Integer
Dim theRange As String
Dim YRange As Range
Dim XRange As Range

theRange = "J" & theRow & ":U" & theRow
'MsgBox (theRow & " " & theCol & " " & theRange)
Set YRange = ActiveSheet.Range(theRange)
Set XRange = ActiveSheet.Range("J4:U4")
TF = Application.WorksheetFunction.Trend(YRange, XRange, theCol)

End Function


--
Regards,
Tom Ogilvy

"alondon" wrote in message
...
Folks,

I can't seem to get this simple function to work

I keep getting an "Unable to get Trend Properties of the Worksheet
Function Class" error. Trend is on the supported
Application.WorksheetFunction list. Perhaps the Trend function is not
supported by VBA - or am I just making a foolish code error?

Below is the Code. On the active sheet, the range J11:U11 contains
product sales numbers between 5.05 and 9.30 (in thousands) and range J4:U4
contains the numbers 1 to 12.

Thanks for your help.

Allan P. London, CPA

__________________________________________________ _
Sub FunctionTest()
MsgBox TF(11, 13)
End Sub
__________________________________________________ _
Function TF(theRow As Integer, theCol As Integer) As Double

Dim I As Integer
Dim theRange As String
Dim YRange As Range
Dim XRange As Range

theRange = "J" & theRow & ":U" & theRow
MsgBox (theRow & " " & theCol & " " & theRange)
Set YRange = ActiveSheet.Range(theRange)
Set XRange = ActiveSheet.Range("J4:U4")
TF = Application.WorksheetFunction.Trend(YRange, XRange, theCol)

End Function




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default WorksheetFunction.Trend doesn't work?

Tom,
Got it, I have to feed Trend only arrays, won't work with single value.
And, it returns only an array, not a single value. Thanks APL

"Tom Ogilvy" wrote in message
...
Sub FunctionTest()
Dim i As Integer
Dim v As Variant
Dim v1 As Variant
ReDim v(1 To 1)
v(1) = 13
i = 11
v1 = TF(i, v)
For i = LBound(v1) To UBound(v1)
Debug.Print i, v1(i)
Next
End Sub

Function TF(theRow As Integer, theCol As Variant)

Dim i As Integer
Dim theRange As String
Dim YRange As Range
Dim XRange As Range

theRange = "J" & theRow & ":U" & theRow
'MsgBox (theRow & " " & theCol & " " & theRange)
Set YRange = ActiveSheet.Range(theRange)
Set XRange = ActiveSheet.Range("J4:U4")
TF = Application.WorksheetFunction.Trend(YRange, XRange, theCol)

End Function


--
Regards,
Tom Ogilvy

"alondon" wrote in message
...
Folks,

I can't seem to get this simple function to work

I keep getting an "Unable to get Trend Properties of the Worksheet
Function Class" error. Trend is on the supported
Application.WorksheetFunction list. Perhaps the Trend function is not
supported by VBA - or am I just making a foolish code error?

Below is the Code. On the active sheet, the range J11:U11 contains
product sales numbers between 5.05 and 9.30 (in thousands) and range
J4:U4 contains the numbers 1 to 12.

Thanks for your help.

Allan P. London, CPA

__________________________________________________ _
Sub FunctionTest()
MsgBox TF(11, 13)
End Sub
__________________________________________________ _
Function TF(theRow As Integer, theCol As Integer) As Double

Dim I As Integer
Dim theRange As String
Dim YRange As Range
Dim XRange As Range

theRange = "J" & theRow & ":U" & theRow
MsgBox (theRow & " " & theCol & " " & theRange)
Set YRange = ActiveSheet.Range(theRange)
Set XRange = ActiveSheet.Range("J4:U4")
TF = Application.WorksheetFunction.Trend(YRange, XRange, theCol)

End Function






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
WorksheetFunction with VBA Ghislain Marcotte Excel Discussion (Misc queries) 2 February 13th 05 07:08 AM
WorkSheetFunction.CountIf & WorkSheetFunction.SumIf with 2 conditions? Etien[_2_] Excel Programming 3 January 13th 04 04:07 PM
WorksheetFunction Mike Fogleman Excel Programming 2 January 1st 04 11:17 PM
WorksheetFunction Stuart[_10_] Excel Programming 3 November 13th 03 12:33 AM
worksheetfunction devnext Excel Programming 1 October 29th 03 12:48 PM


All times are GMT +1. The time now is 08:13 PM.

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"