在VBA中调整范围 [英] Transpose a range in VBA
问题描述
我对VBA很新,对于函数也没有太多的想法。
范围(InRng)。选择
设置范围1 =选择
Dim DestRange As Range
Set DestRange = Application.WorksheetFunction.Transpose(Range1)
经过几个论坛,这是我想出来的。需要注意的是,我不必将它们复制到任何其他单元格中。
我想要实现的是创建协方差方法,在选项窗口中,用户可以选择范围,然后选择列或行,这将影响所得到的协方差矩阵。
这样可以将X和X'作为可以传递的变体数组另一个功能。
Dim X()As Variant
Dim XT()As Variant
X = ActiveSheet.Range(InRng)。Value2
XT = Application.Transpose(X)
要将转置的值作为范围,您必须通过此答案中的工作表传递它。没有看到你的协方差函数如何工作,很难看到你需要什么。
I am Trying to Transpose a range of cells in Excel through VBA macro but I am getting some errors, mostly Error 91.
I am pretty new to VBA and don't have much idea about functions either.
Range(InRng).Select
Set Range1 = Selection
Dim DestRange As Range
Set DestRange = Application.WorksheetFunction.Transpose(Range1)
After going through a couple of forums, this is what I have come up with. One thing to note is that I don't have to copy them into any other cells.
What I am trying to achieve is to create a co-variance method and in the option window the user will have the option to select the range and then choose either by columns or rows, this will then affect the resulting covariance matrix.
This gets you X and X' as variant arrays you can pass to another function.
Dim X() As Variant
Dim XT() As Variant
X = ActiveSheet.Range("InRng").Value2
XT = Application.Transpose(X)
To have the transposed values as a range, you have to pass it via a worksheet as in this answer. Without seeing how your covariance function works it's hard to see what you need.
这篇关于在VBA中调整范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!