作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
嗨,我是 VBA 新手,并创建了一些基本功能,但以下证明太高级了。
我想创建一个将方阵转换为其列之一的函数。
colA colB colC
[1,] 1 2 3
[2,] 4 5 6
[3,] 7 8 9
2
5
8
{Index(G1:G3,Match(2&2,getcol(A1:C3)&getcol(D1:F3),0))}
Function getcol(a As Range, b As Integer) As Range
getcol = Range(a).EntireColumn(b)
End Function
最佳答案
这是你正在尝试的吗?我没有测试过索引/匹配。以下代码仅返回相关范围。你如何使用它取决于你。
Option Explicit
Sub Sample()
Dim rng As Range
Dim truncRange As Range
Set rng = Range("A1:C3")
Set truncRange = getcol(rng, 2)
If Not truncRange Is Nothing Then
MsgBox truncRange.Address
Else
MsgBox "One of the parameters of getcol() is incorrect"
End If
End Sub
Function getcol(a As Range, b As Integer) As Range
Dim rowCount As Long
'~~> Get the total rows in that range
rowCount = a.Rows.Count
'~~> Extract the range from relevant position
Set getcol = Range(a.Cells(1, b), a.Cells(rowCount, b))
End Function
关于excel - 从方阵中选择列向量的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55394770/
我需要编写一个程序,在用户输入行和列时输出以下内容。以下示例适用于 4x4 矩阵: 1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 1
我在 javascript 中有一个小函数,我想将数组 A 拆分为二维数组。I 将用于方阵。显然,如果输入中有 2x2 的方阵,我希望它是 2x2,对于 3x3 依此类推。但在读完第一行后我被卡住了。
如何旋转(或移动)二维方形数组,但不移动任何不在数组“边界”上的元素? 例子: 1 2 3 4 12 13 14 5 11 15 16 6 10 9 8 7 我想要的: 12 1 2 3
第一次在这里问问题。我有点“受阻”。 我有一个由 n x n 数组组成的数组(为简化起见,让 n=3): [ [ [ 0, 1, 2], [ 3, 4,
我是一名优秀的程序员,十分优秀!