ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   slope function with matrix columns as arguments (https://www.excelbanter.com/excel-programming/393633-slope-function-matrix-columns-arguments.html)

adam_6242

slope function with matrix columns as arguments
 
Hello all:

Here is my setup. I have filled n x 3 matrix with values. I would like to
regress columns 1 and 2 of the matrix, individually, against column 3 using
the Slope application. However, I cannot access the columns correctly to
place as the Slope arguments. A sample of my code is below. Suggestions to
my problem are greatly appreciated. Thanks.


For i = 1 To 2
Value(i) = Application.WorksheetFunction.Slope(Matrix.Applica tion.Columns
(i),
Matrix.Application.Columns(3))

MsgBox ("Value " & Value(i))

Next i


Dana DeLouis

slope function with matrix columns as arguments
 
However, I cannot access the columns correctly...

Hi. One way is via Index ...

Sub Demo()
Dim M As Variant
Dim Slp As Double
Dim C As Long

M = [A1:C10].Value
With WorksheetFunction
For C = 1 To 2
Slp = .Slope(.Index(M, 0, 3), .Index(M, 0, C))
Debug.Print Slp
Next C
End With
End Sub

--
HTH :)
Dana DeLouis


"adam_6242" <u35952@uwe wrote in message news:755d5cbdb6fe3@uwe...
Hello all:

Here is my setup. I have filled n x 3 matrix with values. I would like
to
regress columns 1 and 2 of the matrix, individually, against column 3
using
the Slope application. However, I cannot access the columns correctly to
place as the Slope arguments. A sample of my code is below. Suggestions
to
my problem are greatly appreciated. Thanks.


For i = 1 To 2
Value(i) =
Application.WorksheetFunction.Slope(Matrix.Applica tion.Columns
(i),
Matrix.Application.Columns(3))

MsgBox ("Value " & Value(i))

Next i




adam_6242

slope function with matrix columns as arguments
 
Dana:

Thank you for your insights - I applied your suggestions and the code now
works!! I am now aware of the Index functionality - thanks again

Dana DeLouis wrote:
However, I cannot access the columns correctly...


Hi. One way is via Index ...

Sub Demo()
Dim M As Variant
Dim Slp As Double
Dim C As Long

M = [A1:C10].Value
With WorksheetFunction
For C = 1 To 2
Slp = .Slope(.Index(M, 0, 3), .Index(M, 0, C))
Debug.Print Slp
Next C
End With
End Sub

Hello all:

[quoted text clipped - 16 lines]

Next i




All times are GMT +1. The time now is 03:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com