excel - Having issues with creating pivot table with VBA -
so have been able create pivot table , show mean. here code far.
dim wsd worksheet dim ptcache pivotcache dim pt pivottable dim prange range dim finalrow long dim finalcol long dim startpt string set wsd = worksheets("aggregatedata") set wsd2 = worksheets("sheet12") ' select data pivot table finalrow = wsd.cells(rows.count, 2).end(xlup).row finalcol = wsd.cells(1, columns.count).end(xltoleft).column set prange = wsd.cells(2, 1).resize(finalrow, finalcol) set ptcache = activeworkbook.pivotcaches.add(sourcetype:=xldatabase, sourcedata:=prange) 'where want pivot table start startpt = wsd2.range("a1").address(referencestyle:=xlr1c1) 'begin create pivot table set pt = ptcache.createpivottable(tabledestination:=startpt, tablename:="pos data") pt.pivotfields("fineline").orientation = xlrowfield end sub when run code, beginnings of pivot table. however, pivot table appears white instead of blue normal pivot table has. appreciated.
thanks,
g
please replace row set ptcache = activeworkbook.pivotcaches.add(sourcetype:=xldatabase, sourcedata:=prange) of code code set ptcache = activeworkbook.pivotcaches.create(sourcetype:=xldatabase, sourcedata:=prange, version:=xlpivottableversion15) . xlpivottableversion15 standard blue version of pivottable. please confirm if resolves question.
Comments
Post a Comment