我正在基于我的活动表格中的第一行(1)和第一列(A),从名为 Shop
的表格中查找销售额sales
的值,如下所示:
lastRow = Range("A1").End(xlDown).Row
lastColumn = Range("A1").End(xlRight).Column
'i -> rows
For i = 2 to lastRow
shopName = Cells(i, 1).Value
'j -> cols
For j = 2 to lastColumn
shopRegion = Cells(1, j).Value
Cells(i,j).FormulaArray = "=Index(Shop[Sales], Match(1, (RC[" & (1- j) & "] = Shop[Name])*(R[" & (1- i) & "]C = Shop[Region]), 0))"
Next j
Next i
我看到正确的值填充在单元格中。
我想在Excel中的公式框中看到单元格内容而非公式。我尝试了
Application.Evaluate
,但没有成功。(不重要) 是否有办法在
Cells(i,j).FormulaArray
中使用变量shopName
和shopRegion
而不是相对引用RC
?