Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Well, this is not the most elegant of solutions, but I think that it works. I basically took the guts of the two VarCov functions and added them together. It seems to work OK on my machine. My guess as to why it wasn't working before is that the VarCov functions are returning an array, but when your AddMatrix function calls the VarCov function, it is feeding it a range. There are some articles out there on using arrays in formulas, but the workaround below may work for you. Best of luck,
Ben Function AddMatrix(rng As Range) As Variant Dim i As Integer Dim j As Integer Dim colnum As Integer Dim matrix() As Double colnum = rng.Columns.Count ReDim matrix(colnum - 1, colnum - 1) For i = 1 To colnum For j = 1 To colnum matrix(i - 1, j - 1) = Application.WorksheetFunction.Covar(rng.Columns(i) , rng.Columns(j)) + _ Application.WorksheetFunction.Covar(rng.Columns(i) , rng.Columns(j)) Next j Next i AddMatrix = matrix End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Accessing individual elements of an array returned by a function | Excel Programming | |||
Calculate and display individual error bars for individual points | Charts and Charting in Excel | |||
Calculate and display individual error bars for individual points | Charts and Charting in Excel | |||
How to compute the inverse of a matrix with some complex elements | Excel Worksheet Functions | |||
How to do matrix operation with complex number elements in Excel | Excel Worksheet Functions |