Finding The Rows Between Two Pivot Tables and Hiding

mayoung

Active Member
Joined
Mar 26, 2014
Messages
257
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I have two pivot tables on top of each other (Refer To Picture) that are created through VBA. The empty rows between the two pivots is always changing, based on the top pivots data changing, that is the reason for the gap between the pivot tables. Here is the tricky part . How can I select the empty rows between the two pivot tables and hide them. Leaving just two empty rows between them?

13C432C4-3B88-4BA6-84C4-C25014FACC4D.jpeg
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Assuming that your vba always creates that second PT at row 41, try this

VBA Code:
With Range("A41", Range("A41").End(xlUp)).SpecialCells(xlBlanks)
  .Resize(.Rows.Count - 2).EntireRow.Hidden = True
End With

BTW,
I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
Assuming that your vba always creates that second PT at row 41, try this

VBA Code:
With Range("A41", Range("A41").End(xlUp)).SpecialCells(xlBlanks)
  .Resize(.Rows.Count - 2).EntireRow.Hidden = True
End With

BTW,
I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
Updated my account details thank you
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

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