Excel VBA hanging when pasting Pivot table over itself -


the following code hangs when try paste pivot table on itself. i've used same code earlier doesn't work here. i've run through step step find problem. below whole code problem in bold close end of code. i've added whole code in case can see problems higher up, doubt since runs smoothly pasting @ end.

'create pivot store stock issues  dim rowcount long dim wsissues worksheet dim pc pivotcache dim pt pivottable dim pi pivotitem dim pf pivotfield dim lastrow long  set wsissues = worksheets.add     rowcount = worksheets("summary").cells(51, 1).end(xldown).row set pc = activeworkbook.pivotcaches.create(xldatabase, "summary!r51c1:r" & rowcount & "c38") set pt = pc.createpivottable(wsissues.range("a3"))      'speeds code dramatically     pt.manualupdate = true      pt.pivotfields("site")         .orientation = xlrowfield         .position = 1         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)     end     pt.pivotfields("name")         .orientation = xlrowfield         .position = 2         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)     end     pt.pivotfields("ownership")         .orientation = xlrowfield         .position = 3         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)     end     pt.pivotfields("article")         .orientation = xlrowfield         .position = 4         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)     end     pt.pivotfields("article description")         .orientation = xlrowfield         .position = 5         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)     end     pt.pivotfields("promo")         .orientation = xlrowfield         .position = 6         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)         .pivotitems("(blank)").caption = " "     end     pt.pivotfields("vendor")         .orientation = xlrowfield         .position = 7         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)     end     pt.pivotfields("pack size")         .orientation = xlrowfield         .position = 8         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)     end      wsissues.pivottables(1).name = "stockissues"      pt.pivotfields("ms")         .orientation = xlrowfield         .position = 9         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)         .pivotfilters.add type:=xlcaptionequals, value1:="4"     end     pt.pivotfields("listing status")         .orientation = xlrowfield         .position = 10         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)         .pivotfilters.add type:=xlcaptionequals, value1:="listed"     end     pt.pivotfields("rp type")         .orientation = xlrowfield         .position = 11         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)         .pivotfilters.add type:=xlcaptionequals, value1:="roster"     end      pt.pivotfields("oos no soo")         .orientation = xlrowfield         .position = 12         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)     end     pt.pivotfields("oos soo")         .orientation = xlrowfield         .position = 13         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)     end     pt.pivotfields("soh no soo")         .orientation = xlrowfield         .position = 14         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)     end     pt.pivotfields("negative stock")         .orientation = xlrowfield         .position = 15         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)     end     pt.pivotfields("overstock")         .orientation = xlrowfield         .position = 16         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)     end     pt.pivotfields("dormant stock")         .orientation = xlrowfield         .position = 17         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)     end     pt.pivotfields("outdated stock counts")         .orientation = xlrowfield         .position = 18         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)     end     pt.pivotfields("total issues")         .orientation = xlrowfield         .position = 19         .subtotals = array(false, false, false, false, false, false, false, false, false, false, false, false)     end      pt         .showdrillindicators = false         .ingriddropzones = true         .rowaxislayout xltabularrow     end      pt.repeatalllabels xlrepeatlabels      pt         .columngrand = false         .rowgrand = false     end      pt.manualupdate = false      wsissues.pivottables("stockissues").tablerange2         .copy         **.pastespecial paste:=xlpastevalues**     end      application.wait (now + timevalue("0:00:02")) 

i've ran code slight modification, , worked fine:

' defined , set pt object, why not use pt.tablerange2.copy '<-- copy tablerange2 of pivot-table  ' paste range "a3" wsissues.range("a3").pastespecial xlpastevalues 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -