I get the error code 1004 "unable to get the label range property of the pivot field class"
for the pivot code below:
Sub DateFilter_DAILY()
Sheets("Sales").Activate
'Set the Variables to be used
Dim pt As PivotTable
Set pt = Worksheets("ORDERBOOK").PivotTables("PivotTable4")
pt.PivotCache.REFRESH
'Group Date Field by Month
pt.RowAxisLayout xlTabularRow
Set df = pt.PivotFields("so_invoice_date")
df.LabelRange.Group _
Start:=True, End:=True, _
Periods:=Array(False, False, False, False, True, False, True) 'Seconds-->Minutes-->Hours-->Days-->Months-->Quarters-->Years
pt.RowAxisLayout xlCompactRow
'Set day range on pivot
pt.PivotFields("so_invoice_date").ClearAllFilters 'This line is needed to clear existing filter before applying new one
pt.PivotFields("so_invoice_date").PivotFilters.Add Type:=xlDateBetween, _
Value1:=CLng((Range("u4").Value)), Value2:=CLng((Range("v4").Value))
'Group Date Field by Day
pt.RowAxisLayout xlTabularRow
Set df = pt.PivotFields("so_invoice_date")
df.LabelRange.Group _
Start:=True, End:=True, _
Periods:=Array(False, False, False, True, True, False, True) 'Seconds-->Minutes-->Hours-->Days-->Months-->Quarters-->Years
pt.RowAxisLayout xlCompactRow
Application.DisplayAlerts = False
please help
End Sub
for the pivot code below:
Sub DateFilter_DAILY()
Sheets("Sales").Activate
'Set the Variables to be used
Dim pt As PivotTable
Set pt = Worksheets("ORDERBOOK").PivotTables("PivotTable4")
pt.PivotCache.REFRESH
'Group Date Field by Month
pt.RowAxisLayout xlTabularRow
Set df = pt.PivotFields("so_invoice_date")
df.LabelRange.Group _
Start:=True, End:=True, _
Periods:=Array(False, False, False, False, True, False, True) 'Seconds-->Minutes-->Hours-->Days-->Months-->Quarters-->Years
pt.RowAxisLayout xlCompactRow
'Set day range on pivot
pt.PivotFields("so_invoice_date").ClearAllFilters 'This line is needed to clear existing filter before applying new one
pt.PivotFields("so_invoice_date").PivotFilters.Add Type:=xlDateBetween, _
Value1:=CLng((Range("u4").Value)), Value2:=CLng((Range("v4").Value))
'Group Date Field by Day
pt.RowAxisLayout xlTabularRow
Set df = pt.PivotFields("so_invoice_date")
df.LabelRange.Group _
Start:=True, End:=True, _
Periods:=Array(False, False, False, True, True, False, True) 'Seconds-->Minutes-->Hours-->Days-->Months-->Quarters-->Years
pt.RowAxisLayout xlCompactRow
Application.DisplayAlerts = False
please help
End Sub