S
Spacedman
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("Date")
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
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("Date")
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