Insert a blank row below a Pivot Table VBA

Jeevz_87

New Member
Joined
Sep 21, 2021
Messages
37
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I have a workbook which has two pivot tables stacked on top of each other which are likely to grow in the coming months as the source data is updated.
What I'm looking for is a macro that can find the bottom of these pivot tables and insert two blank row(s) each to mitigate any overlap errors as the pivot tables increase in size.
Is there a simple piece VBA code to do this?

Thanks,

Jvz_87
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
i'd prefer a solution with 100 hidden rows between both and unhide those rows when the 1st pivottable "grows"
 
Upvote 0
That's exactly what I have at the moment and normally I have no issue with it but I was wondering if there is a more elegant solution to this issue?
 
Upvote 0
or something like this
VBA Code:
Sub Macro1()
     Set c1 = ActiveSheet.PivotTables(1).TableRange2            '1st pvt
     Set c2 = ActiveSheet.PivotTables(2).TableRange2            '2nd pvt

     MsgBox c1.Address & vbLf & c2.Address

     ActiveSheet.PivotTables(2).Location = "'" & ActiveSheet.Name & "'!" & c1.Cells(c1.Rows.Count + 5, 1).Address     '2nd pivottable 5 rows below 1st

End Sub
adjust that 5 for the number of rows your pivottable is max growing everytime.
 
Upvote 0

Forum statistics

Threads
1,214,586
Messages
6,120,402
Members
448,958
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top