VBA 公式数组范围 class 当字符少于 255 时出错
VBA FormulaArray range class error when the Characters are less than 255
VBA.FormulaArray 似乎对我的范围有问题。我读过它不能处理超过 255 个字符,但我的只有大约 108 个,但我可能理解错了。
它给出了
Error 1004:
Unable to set FormulaArray property of the Range class.
我试过将公式留在 table 列中,并让它在 table 填充宏时自动填充,但问题是索引数组 table 在宏开始之前还不存在 运行.
还尝试将其保留为文本,然后将列更改为 "general",但它不起作用。而且我知道以这种方式将其更改为数组公式也会产生问题。
这是我正在使用的代码:
With wsOutdated.ListObjects("Table_Outdated_Stock_Counts")
.ListColumns("Ranging").DataBodyRange.NumberFormat = "General"
.ListColumns("Ranging").DataBodyRange.FormulaArray = "=INDEX(Table_DispoData[[Class]],MATCH([@Article]&[@Site],Table_DispoData[Article]&Table_DispoData[Site],0),1)"
End With
我需要 table 列自动填充数组公式。
它适用于其他列(虽然它们不是数组公式,只需要匹配单个值)。
也许你可以试试:
.ListColumns("Ranging").DataBodyRange.Cells(1, 1).FormulaArray = "=INDEX(Table_DispoData[[Class]],MATCH([@Article]&[@Site],Table_DispoData[Article]&Table_DispoData[Site],0),1)"
而不是:
.ListColumns("Ranging").DataBodyRange.FormulaArray = "=INDEX(Table_DispoData[[Class]],MATCH([@Article]&[@Site],Table_DispoData[Article]&Table_DispoData[Site],0),1)"
看看它是否适合你!
解释:
Your code is trying to write Array formula to multiple cells simultaneously which is not allowed.
If you try to do this in Excel then it will return an error "Multi-cell array formulas aren't allowed in tables".
VBA.FormulaArray 似乎对我的范围有问题。我读过它不能处理超过 255 个字符,但我的只有大约 108 个,但我可能理解错了。
它给出了
Error 1004:
Unable to set FormulaArray property of the Range class.
我试过将公式留在 table 列中,并让它在 table 填充宏时自动填充,但问题是索引数组 table 在宏开始之前还不存在 运行.
还尝试将其保留为文本,然后将列更改为 "general",但它不起作用。而且我知道以这种方式将其更改为数组公式也会产生问题。
这是我正在使用的代码:
With wsOutdated.ListObjects("Table_Outdated_Stock_Counts")
.ListColumns("Ranging").DataBodyRange.NumberFormat = "General"
.ListColumns("Ranging").DataBodyRange.FormulaArray = "=INDEX(Table_DispoData[[Class]],MATCH([@Article]&[@Site],Table_DispoData[Article]&Table_DispoData[Site],0),1)"
End With
我需要 table 列自动填充数组公式。 它适用于其他列(虽然它们不是数组公式,只需要匹配单个值)。
也许你可以试试:
.ListColumns("Ranging").DataBodyRange.Cells(1, 1).FormulaArray = "=INDEX(Table_DispoData[[Class]],MATCH([@Article]&[@Site],Table_DispoData[Article]&Table_DispoData[Site],0),1)"
而不是:
.ListColumns("Ranging").DataBodyRange.FormulaArray = "=INDEX(Table_DispoData[[Class]],MATCH([@Article]&[@Site],Table_DispoData[Article]&Table_DispoData[Site],0),1)"
看看它是否适合你!
解释:
Your code is trying to write Array formula to multiple cells simultaneously which is not allowed. If you try to do this in Excel then it will return an error "Multi-cell array formulas aren't allowed in tables".