Excelmacros可与2007或2010一起使用

我已经写了一个Excelmacros来sorting和突出显示条件格式的数据

= $ A1 = TODAY()=>使用黄色字体

当我在2007年写了它,并在2010年执行它,使$ A 16或东西。 2010年重写它在2010年工作正常,但在2007年执行它使用1048572 (1024 * 1024 – 4)我想这是某种算术溢出。

我仔细检查了源代码,这似乎是好的,在所有正确的地方说“$ A1”。 它只是不这样做,因为它在那里。

编译器或2010年使用双引号在2007年使用单个或任何东西有区别吗?

编辑:

Selection.FormatConditions(1).StopIfTrue = False Cells.FormatConditions.Delete Columns("A:S").Select Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$A1=HEUTE()" Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority With Selection.FormatConditions(1).Interior .PatternColorIndex = xlAutomatic .Color = 65535 .TintAndShade = 0 End With Selection.FormatConditions(1).StopIfTrue = False 

我把它归咎于第四行。 HEUTE()TODAY()

我认为它在2007年的一些奇怪的行为:

如果使用vba设置格式条件,则会设置所有相对于活动单元格的范围,因此如果C3是活动单元格,则公式中的C3将成为A1(a D3 a B1)

以下可能会有所帮助(在列(“A:S”)之后)select)

 Range("A1").Activate