Table 公式在 Excel VBA 2007 年无效,而在 2013 年有效

Table formula is not working in Excel VBA 2007 where as it works on 2013

我创建了一个 VBA 代码,它将公式放在格式化的 Table 的末尾。这段代码在 2013 年运行完美,但当我将它部署在 2007 年的客户端时,它在其中一个公式中抛出错误。公式为:

formula = "=Text([@[SO '#]],""0000000000"")&""|""&[@[Item '#]]"

列名是 "SO #" 和 "Item #" 单撇号用作转义字符。我觉得在 2007 年,情况有所不同。有人可以快速给我建议解决方案吗?

在 Excel 2007 年,@ 符号还不是结构化引用符号的一部分。它使用 #This Row 代替。

比较 MS Excel 2010 公式:

=VLOOKUP(Table1[@LoanNumber], Table2[#All], MATCH(Table2[@Column10],Table2[@], 0), FALSE)

MS Excel 2007 公式:

=VLOOKUP(Table1[[#This Row],[LoanNumber]], Table2[#All], MATCH(Table2[[#This Row],[Column10]],Table2[#This Row], 0), FALSE)

一般来说,避免在列名称中使用 # 等特殊字符可能是个好主意,因为这会使公式很难阅读。