ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   error 1004 when setting pivottable.pagefields (https://www.excelbanter.com/excel-discussion-misc-queries/203722-error-1004-when-setting-pivottable-pagefields.html)

Amedee Van Gasse

error 1004 when setting pivottable.pagefields
 
A code snippet:

Function FillYearMonth(ByVal theWorkbook As String, ByVal theWorkSheet
As String, _
ByVal thePivotTable As String, ByVal thePageField As String)
Dim ws As Worksheet
Set ws = Worksheets(theWorkSheet)
Dim pt As PivotTable
Set pt = ws.PivotTables(thePivotTable)
Dim pf As PivotField
Set pf = pt.PageFields(thePageField)
Dim lb As ListBox
Set lb = Worksheets(theWorkSheet).lstYearMonth
Call FillListBox(pf, lb)
End Function

I keep getting error 1004 after executing the line
Set pf = pt.PageFields(thePageField)


Can anyone point me what is wrong in this code?


--
Amedee


All times are GMT +1. The time now is 10:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com