简体   繁体   English

表格公式在Excel VBA 2007中不起作用,因为它适用于2013年

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

I have created a VBA code which puts a formula at the end of formatted Table. 我创建了一个VBA代码,它将公式放在格式化表的末尾。 This code is working flawlessly in 2013 but as I deployed it at client side which has 2007, it is throwing error at one of the formula. 这段代码在2013年完美运行,但是当我在2007年的客户端进行部署时,它会在其中一个公式上抛出错误。 Formula is: 公式是:

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

Column names are "SO #" and "Item #" Single apostrophe is used as escape character. 列名称为“SO#”和“Item#”单撇号用作转义字符。 I feel that in 2007 this behaves differently. 我觉得在2007年这种行为有所不同。 Can someone suggest me a solution to this quickly? 有人能建议我快速解决这个问题吗?

In Excel 2007 the @ sign was not yet part of the structured reference notation. 在Excel 2007中,@符号尚未成为结构化引用表示法的一部分。 It used #This Row instead. 它使用#This Row代替。

Compare MS Excel 2010 Formula: 比较MS Excel 2010公式:

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

MS Excel 2007 Formula: MS Excel 2007公式:

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

In general, it might be a good idea to avoid special characters like # in column names, because that makes formulas really hard to read. 一般来说,在列名中避免像#这样的特殊字符可能是一个好主意,因为这会使公式很难阅读。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM