PDA

View Full Version : Pivot Table from dynamic range



Amosad
04-19-2016, 07:52 AM
Hi Guys,

I'm using the offset function to define a dynamic range for my DB

through VBA i want to build a pivot table from this range

this code used to work for me but now it does not and i don't know why:

" Set srcsht = mywb.Sheets.Add Startpvt = srcsht.Name & "!" & srcsht.Range("A3").Address(ReferenceStyle:=xlR1C1)
Set pvtCache = ActiveWorkbook.PivotCaches.Create( _
SourceType:=xlDatabase, _
SourceData:=Range("RTW_DB"))


Set pvt = pvtCache.CreatePivotTable( _
TableDestination:=Startpvt, _
TableName:="PivotTable1") "

RTW_DB is the name of the offset range. this code worked for me before, for some reason now it throws me from the function

Please help me! :dunno