Excel VBA Changing Data Source for Pivot Table -
okay, have sifted through tons of posts , cannot code run. trying create reconciliation report, have running fine. problem comes when trying take each month's report , paste master reconciliation file. have working perfectly, except cannot life of me figure out why pivot table source won't change.
the error getting code is:
run-time error '1004': application-defined or object-defined error
any suggestions? :-\
dim srcdata string dim pivtbl pivottable srcdata = activesheet.name & "!" & range("$a$1:$h$" & lastrow).address(referencestyle:=xlr1c1) on error resume next set pivtbl = sheets("report").pivottables("reportpivot") on error goto 0 if pivtbl nothing 'create pivot else activeworkbook.pivottables(pivtbl).changepivotcache activeworkbook. _ pivotcaches.create(sourcetype:=xldatabase, sourcedata:=srcdata, _ version:=xlpivottableversion15) pivtbl.refreshtable end if
since problem here:
activeworkbook.pivottables(pivtbl).changepivotcache activeworkbook. _ pivotcaches.create(sourcetype:=xldatabase, sourcedata:=srcdata, _ version:=xlpivottableversion15)
i guess cannot pivot table passing table argument: .pivottables(pivtbl)
pivtbl
table want.
pivtbl.changepivotcache.......
Comments
Post a Comment