我有这个宏和
Sheets("Query[Difference in date]").Formula = "=[Posting Date]-[Expected Receipt Date]"
和
Sheets("Query[Grade]").Formula = _
"=IF([Difference in date]<2,""A"",IF([Difference in date]=2,""B"",IF([Difference in date]=3,""C"",IF([Difference in date]=4,""D"",""F""))))"
正在给我一个
错误9 - 下标超出范围错误。
有什么建议吗?
Sheets("Query").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Range("K2").Select
ActiveCell.FormulaR1C1 = "Difference in date"
Range("K3").Select
Sheets("Query[Difference in date]").Formula = "=[Posting Date]-[Expected Receipt Date]"
Range("L2").Select
ActiveCell.FormulaR1C1 = "Grade"
Range("L3").Select
Sheets("Query[Grade]").Formula = "=IF([Difference in date]<2,""A"",IF([Difference in date]=2,""B"",IF([Difference in date]=3,""C"",IF([Difference in date]=4,""D"",""F""))))"
Sheets("Pivot Table").Select
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
此宏刷新查询表,然后使用公式向右添加两列,然后刷新引用查询表的数据透视表。