excel - Run-time error '1004' Pivot table error -
i looking assistance following error.
i have vba code opens workbook , copies in sheet containing pivot table.
the code selects pivot table, filters date, , copies fields out.
this functionality works on first time use. however, when report used more once in day, hits following error:
the issue assignment of pivot table name, vba uses system defaults. code follows:
sheets("sheet1").select activeworkbook.showpivottablefieldlist = false activesheet.pivottables("pivottable1").pivotfields("date ").autosort _ xldescending, "date "
is there alternative way dynamically select pivot table regardless of name?
alternatively, there code clear history @ end of execution every time report run pivot 1?
any appreciated.
thanks in advance
if know there 1 pivot table (as seems have intended in post convey, though may have misinterpretted this), better use index name, name different if new pivot table created while had existed. change call to:
if sheets("sheet1").pivottables.count <> 0 sheets("sheet1").pivottables(1).pivotfields("date ").autosort xldescending, "date " end if
note removed "select" usage, considered bad practice variety of reasons.
Comments
Post a Comment