PDA

View Full Version : PIvot Tabel macro no longer works since upgrade to Excel 2007



peacenik
11-04-2009, 06:39 PM
I have a macro acting on a pivot table that worked beautifully in Excel 2003, but last week we upgraded to Excel 2007 and now it doesn't work.

It doesn't throw any errors, but it doesn't make these items invisible either.

Sub Showthisweekonly()
'
' Macro6 Macro
' Macro recorded 5/06/2009 by Paul Sinclair
'
On Error GoTo Errorhandler
Application.ScreenUpdating = False
Today = Format(Now(), "dd/mm/yyyy")
Todayless1 = Format(Now() - 1, "d/m/yyyy")
Todayless2 = Format(Now() - 2, "d/m/yyyy")
Todayless3 = Format(Now() - 3, "d/m/yyyy")
Todayless4 = Format(Now() - 4, "d/m/yyyy")
Todayless5 = Format(Now() - 5, "d/m/yyyy")
Todayless6 = Format(Now() - 6, "d/m/yyyy")
Todayless7 = Format(Now() - 7, "d/m/yyyy")

For Each pItem In Sheet1.PivotTables("PivotTable1").PivotFields("SaleDate").PivotItems
Select Case pItem.Name
Case Today, Todayless1, Todayless2, Todayless3, Todayless4, Todayless5, Todayless6, Todayless7
pItem.Visible = True
Case Else
pItem.Visible = False

End Select
Next
Application.ScreenUpdating = False
Exit Sub
Errorhandler:
Select Case Err.Number
Case 13
Resume
End Select

End Sub

Please help.