代码之家  ›  专栏  ›  技术社区  ›  J.Doe

在选择中对非cte范围使用MMult时出现连接困难。VBA公式

vba
  •  0
  • J.Doe  · 技术社区  · 8 年前

    正如您可能怀疑的那样,如果程序用户更改Excel中单元格的值,则temp1和temp2变量会发生变化,因此范围不是恒定的,并且不是这些变量的函数。

    Range(Cells(9, 7 + 2 * temp2 + 1), Cells(8 + temp2, 7 + 2 * temp2 + 1)).Select
    Selection.FormulaArray = _
         "=MMULT(" & Range(Cells(9, 7 + temp2), Cells(8 + temp2, 7 + 2 * temp2 - 1)) & ",MMULT(TRANSPOSE(" & Range(Cells(9, 6), Cells(9 + temp1, 5 + temp2)) & ")," & Range(Cells(9, 3), Cells(9 + temp1, 3)) & "))"
    
    1 回复  |  直到 8 年前
        1
  •  0
  •   YowE3K    8 年前

    在没有任何线索的情况下,关于你在哪一行得到了什么错误,我将在黑暗中尝试,并建议你在尝试将二维数组连接到 String .

    认为

    Range(Cells(9, 7 + 2 * temp2 + 1), Cells(8 + temp2, 7 + 2 * temp2 + 1)).FormulaArray = _
     "=MMULT(" & Range(Cells(9, 7 + temp2), Cells(8 + temp2, 7 + 2 * temp2 - 1)).Address & _
     ",MMULT(TRANSPOSE(" & Range(Cells(9, 6), Cells(9 + temp1, 5 + temp2)).Address & _
     ")," & Range(Cells(9, 3), Cells(9 + temp1, 3)).Address & "))"
    

    i、 e.使用 .Address 您的财产 Range 对象,而不是使用(默认) .Value