Excel VBA worksheetfunction.transpose returns dimensions but no values

user3933289

This code is originally much longer and intends to use Savitsky-golay fitting to take derivative estimates. In order to take find the derivative matrix needed to fit against original data, I need to follow through a series of excel worksheet functions (namely: Golay_matrix=MMult(MInverse(MMult(Transpose(matrix), matrix)), Transpose(matrix))) I'm relatively new to excel vba and feel like I have exhausted most avaiable resouces trying to solve what appears to be a WorksheetFunction problem. I can code in a transpose function myself, but I would rather not try to code in a MInverse function.. since eventually I will need to use MInverse, MMult, etc., I figured it best if I figured out what was going wrong with the front portion of my code.

I would love any bit of your help!! Thanks!!

Function d_ar(ends As Integer, fit As Integer) As Double()
Dim lngt As Integer 'length of "huge" array
Dim i As Integer
Dim n As Integer
lngt = ends * 2 + 1

Dim huge() As Variant 'array to transpose

For i = 1 To fit + 1
    For n = 1 To lngt
        ReDim huge(1 To n, 1 To i)
        huge(n, i) = (-ends + n - 1) ^ (i - 1)
    Next n
Next i
Dim t_hg() As Variant 'transpose of "huge" matrix
ReDim t_hg(1 To i - 1, 1 To n - 1) 
t_hg = Application.WorksheetFunction.Transpose(huge)
Cells(1, 15).value = t_hg(1, 2) 'value of zero is returned, but should be -7
End Function
MP24

You are ReDiming your huge array in the for loop, and ReDim by default zeros out the array. If you want to preserve existing values, you will need to use ReDim Preserve huge(1 To n, 1 To i).

In addition, wouldn't it be sufficient to set the array size once before the for loops?

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Trouble with WorksheetFunction in Excel VBA

From Dev

Add transpose to excel VBA

From Dev

Excel VBA WorksheetFunction.IsError false positive

From Dev

VBA Excel WorksheetFunction.Rank issue

From Dev

Excel vba percentile worksheetfunction function with collection argument

From Dev

usage of WorksheetFunction.Year in excel vba For loop

From Dev

Excel VBA code for copy and transpose

From Dev

VBA EXCEL: Use value in Listbox as Lookup value in the Match WorksheetFunction

From Dev

Excel VBA: Error 1004 WorkSheetFunction 'Unable to get Vlookup property"

From Dev

WorksheetFunction.Match multiple sheets Excel VBA error 1004

From Dev

Application.worksheetFunction.match not working correctly VBA Excel

From Dev

MS office 2016 excel paste values with transpose

From Dev

Adding an image to a range with original dimensions in excel vba

From Dev

From Excel get the dimensions of a shape in PowerPoint with VBA

From Dev

repmat and/or transpose into singleton dimensions

From Dev

VBA WorksheetFunction dynamic randbetween

From Dev

Excel VBA - Paste as values

From Dev

Excel VBA Range returns empty

From Dev

TypeName in Excel VBA returns what?

From Dev

VBA Evaluate 'IF' with 'OR' returns wrong values

From Dev

Excel VBA code to transpose data from rows to columns

From Dev

Excel VBA - transpose formulas in vertical array to horizontal array

From Dev

Excel VBA Transpose contiguous range each empty cell

From Dev

Excel VBA Transpose dynamic list with repeating header to new sheet

From Dev

(VBA) Excel with thousands of rows - how to transpose variable length columns to rows?

From Dev

EXCEL VBA Transpose multiple columns to multiple rows with gaps inbetween columns

From Dev

VBA - Best Way to Distinct the values and transpose the data next to them?

From Dev

Excel VBA: Can't get a match, error "Unable to get the Match property of the WorksheetFunction class"

From Dev

EXCEL VBA - how to pass # of filled cells inside a custom range, into the "i" variable using Application.WorksheetFunction.CountA?

Related Related

  1. 1

    Trouble with WorksheetFunction in Excel VBA

  2. 2

    Add transpose to excel VBA

  3. 3

    Excel VBA WorksheetFunction.IsError false positive

  4. 4

    VBA Excel WorksheetFunction.Rank issue

  5. 5

    Excel vba percentile worksheetfunction function with collection argument

  6. 6

    usage of WorksheetFunction.Year in excel vba For loop

  7. 7

    Excel VBA code for copy and transpose

  8. 8

    VBA EXCEL: Use value in Listbox as Lookup value in the Match WorksheetFunction

  9. 9

    Excel VBA: Error 1004 WorkSheetFunction 'Unable to get Vlookup property"

  10. 10

    WorksheetFunction.Match multiple sheets Excel VBA error 1004

  11. 11

    Application.worksheetFunction.match not working correctly VBA Excel

  12. 12

    MS office 2016 excel paste values with transpose

  13. 13

    Adding an image to a range with original dimensions in excel vba

  14. 14

    From Excel get the dimensions of a shape in PowerPoint with VBA

  15. 15

    repmat and/or transpose into singleton dimensions

  16. 16

    VBA WorksheetFunction dynamic randbetween

  17. 17

    Excel VBA - Paste as values

  18. 18

    Excel VBA Range returns empty

  19. 19

    TypeName in Excel VBA returns what?

  20. 20

    VBA Evaluate 'IF' with 'OR' returns wrong values

  21. 21

    Excel VBA code to transpose data from rows to columns

  22. 22

    Excel VBA - transpose formulas in vertical array to horizontal array

  23. 23

    Excel VBA Transpose contiguous range each empty cell

  24. 24

    Excel VBA Transpose dynamic list with repeating header to new sheet

  25. 25

    (VBA) Excel with thousands of rows - how to transpose variable length columns to rows?

  26. 26

    EXCEL VBA Transpose multiple columns to multiple rows with gaps inbetween columns

  27. 27

    VBA - Best Way to Distinct the values and transpose the data next to them?

  28. 28

    Excel VBA: Can't get a match, error "Unable to get the Match property of the WorksheetFunction class"

  29. 29

    EXCEL VBA - how to pass # of filled cells inside a custom range, into the "i" variable using Application.WorksheetFunction.CountA?

HotTag

Archive