Running code, but it debugs at statement dim pt as pivottable: Compile error: A module is not a valid type??
sub createpivottable ()
dim pc as pivotcache
dim pt as pivottable
set pc = thisworkbook.pivotcaches.create(sourcetype:=xldatabase, sourcedata:= sheet1.name & sheet1.range("B4").currentregion.address, version:=xlpivottableversion15)
worksheets.add
range("A3").select
set pt = pc.createpivottable(tabledestination:=Activecell,Tablename:="Pivot")
end sub
sub createpivottable ()
dim pc as pivotcache
dim pt as pivottable
set pc = thisworkbook.pivotcaches.create(sourcetype:=xldatabase, sourcedata:= sheet1.name & sheet1.range("B4").currentregion.address, version:=xlpivottableversion15)
worksheets.add
range("A3").select
set pt = pc.createpivottable(tabledestination:=Activecell,Tablename:="Pivot")
end sub