Excel2007 VBA - dates in Pivot Tables not read in correct format
If I create a PivotTable with a field called DATE containing dates formatting
as dd/mm/yy, I then use this macro to remove Saturdays and Sundays from the PivotTable. Except it reads the dates a mm/dd/yy until they are 'out of scope' and then they are read as dd/mm/yy. Why? Sub HideWeekendsFromPivotTable() Dim pivotName As String Dim pivotDate As Date Dim z, pivotCount As Long pivotName = ActiveSheet.PivotTables(1).Name With ActiveSheet.PivotTables(pivotName).PivotFields("Da te") pivotCount = .PivotItems.Count For z = 1 To pivotCount If Weekday(.PivotItems(z).Name) = 1 Or Weekday(.PivotItems(z).Name) = 7 Then _ .PivotItems(z).Visible = False Next z End With End Sub |
All times are GMT +1. The time now is 08:10 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com