How can I move the location of a pivot table in order to ensure it will not overlap with another pivot table below on refresh?
I have 10 pivot tables whose column span is always equal to A:E.
The rows will dynamically update as the pivots refresh.
I want there to be 2 blank rows before each new pivot table starts so I am using the following workaround
(other questions indicate you cannot directly insert rows as a pivot table refreshes to stop them from overlapping which is the root problem I am trying to curb/workaround)
- Disable auto-calculation
- Loop through all pivots (
pvt) - Offset pivot by
(LRow, 6).... New column span is nowG:K - Refresh Pivot (which will update
LRowon next loop as the table resizes) - Next Pivot
- Re-enable auto-calculate & delete Columns
A:Fwhich means the pivots will be back in their original starting point spanning columnsA:Ewhile leaving 2 empty rows in-between each pivot.
The problem is with pvt.PivotTableWizard TableDestination:=Range("G" & lrow) which does not move the pivot table (or appear to do anything).
Sub MovePivots()
Dim pvt As PivotTable, LRow As Long
Application.Calculation = xlCalculationManual
For Each pvt In PivotTables
LRow = Range("G" & Rows.Count).End(xlUp).Offset(2).Row
pvt.PivotTableWizard TableDestination:=Range("G" & LRow)
pvt.PivotCache.Refresh
Next pvt
Application.Calculation = xlCalculationAutomatic
Range("A:F").EntireColumn.Delete
End Sub
PivotTable.PivotTableWizardMethod creates and returns aPivotTableobject - you can't use it to loop through existing pivot tables and move them. 2. This might get tricky; in testing, Excel did not necessarily loop through the pivot tables from the top of the page down. - BigBen.Locationproperty but there isn't much reading info on that. Most questions seem to say how to move a chart, and I could not extend to a pivot. So here I am, at the mercy of SO (clenches) - urdearboyPivotTable.TableRange2.Cutshould move it. - BigBen