excel vba - Pivot table creation has an unusual activity when done manually vs. VBA -


okay, recorded macro create pivot table. problem simple , annoying. selecting(using vba) columns , rows data in them on 1 sheet named "data" , making pivot table on sheet named "pivot". when run macro, not showing last column("days late") in field list, whereas when select same thing manually , insert pivot table, shows fields. doing wrong such simple step, have no idea?

sheets("pivot").select  range("a:r").delete  sheets("data").select  range(selection, selection.end(xltoright)).select range(selection, selection.end(xldown)).select  activeworkbook.pivotcaches.create(sourcetype:=xldatabase, sourcedata:= _     "data!r1c1:r1000c16", version:=xlpivottableversion15).createpivottable _     tabledestination:="pivot!r2c1", tablename:="pivottable1", defaultversion _     :=xlpivottableversion15  sheets("pivot").select cells(1, 1).select      activesheet.pivottables("pivottable1").pivotfields("vendor name")      .orientation = xlrowfield     .position = 1 end with activesheet.pivottables("pivottable1").pivotfields("planner")     .orientation = xlrowfield     .position = 2 end with activesheet.pivottables("pivottable1").pivotfields("part number")     .orientation = xlrowfield     .position = 3 end with activesheet.pivottables("pivottable1").pivotfields("reason code")     .orientation = xlrowfield     .position = 4 end with activesheet.pivottables("pivottable1").pivotfields("comments")     .orientation = xlrowfield     .position = 5 end with activesheet.pivottables("pivottable1").pivotfields("quantity outstanding")     .orientation = xlrowfield     .position = 6 end with activesheet.pivottables("pivottable1").pivotfields("need date")     .orientation = xlrowfield     .position = 7 end with activesheet.pivottables("pivottable1").pivotfields("days late")     .orientation = xlrowfield     .position = 8 end with activesheet.pivottables("pivottable1").pivotfields("release number")     .orientation = xlrowfield     .position = 9 end 

data sheet

pivot fields list

this issue have come across before , caused order of events. when macro recorder thing - literal, , that's why doesn't work when 'plays back'

i @ re-ordering events (the statements) see if helps


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -