excel - Pivot Table with vba -


i'm trying create pivot table using vba. need code take sheet , create pivot using data in it. columns in pivot need: "years" first , "document date" row "arrears after net due date" values need sum of "amount"

i tried code below gives me "object required error" i've never make pivots before i'm not sure if i'm on right track.

sub newpvt()  set rng = wsa.range("a1:aa100000") set rngdata = range(rng, rng.end(xltoright)) set rngdata = range(rng, rng.end(xldown)) set rngb = wsb.range("c8")  activeworkbook.pivotcaches.create(sourcetype:=xldatabase,      sourcedata:=rngdata, version:=xlpivottableversion14).createpivottable      tabledestination:=rngb, tablename:="pvtreporta_b",      defaultversion:=xlpivottableversion14  end sub 

you need assign pivot table object:

sub newpvt()  dim rng range, rngdata range, rngb range dim pvt pivottable    set wsa = worksheets("name of sheet") set rng = wsa.range("a1:aa100000") set rngdata = range(rng, rng.end(xltoright)) set rngdata = range(rng, rng.end(xldown)) set rngb = wsb.range("c8")  set pvt = activeworkbook.pivotcaches.create(sourcetype:=xldatabase,      sourcedata:=rngdata, version:=xlpivottableversion14).createpivottable      tabledestination:=rngb, tablename:="pvtreporta_b",      defaultversion:=xlpivottableversion14  end sub 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -