Pivot Table Drillthrough

arom

New Member
Joined
Jul 24, 2008
Messages
23
I have a pivot table based on data that has about 10 columns. I was just wondering if it's possible that when I drill through the table, I will only see some of those columns. Basically, can I control the drillthrough or will I always see all the columns of the data source?

Hope this makes sense. Thanks in advance.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
The short answer is that you will always see all the columns. You can use some vb code to make it hide or delete columns, but that can get complicated. But there isn't a built-in feature to only show the columns or data that is on the pivot table unfortunately.
 
Upvote 0
That's what I thought- thanks for your response.

What you are suggesting, I found someone's code that does exactly that:

Private Sub Worksheet_Deactivate()
If Left(ActiveSheet.Name, 5) = "Sheet" Then
ActiveSheet.Range("O").Delete
ActiveSheet.Range("M").Delete
ActiveSheet.Range("B:F").Delete
End If
End Sub

But I put this in "ThisWorkbook" (I assumed that's where it goes) and it doesn't work for me.. Those columns do not get deleted when I drill down.. any thoughts?

Thanks again.
 
Upvote 0
It needs to go in the pivot table sheet code and it will delete data on any sheet that begins with "Sheet" just as a caution.

Hope that helps.
 
Upvote 0
Ah! I just saw that it's your code from another post! Sorry, didn't realize before... Anyway- it doesn't work for me.... Did this work for you?
 
Upvote 0
Ok I'm putting the code on the right sheet- because it's calling the macro. However, I am getting an error. this is the code:

Private Sub Worksheet_Deactivate()
If Left(ActiveSheet.Name, 5) = "Sheet" Then
ActiveSheet.Range("B").Delete
End If
End Sub


It's highlighting the 3rd row (activesheet...).

Not sure why.
 
Upvote 0
Try this:

Code:
Private Sub Worksheet_Deactivate()
If Left(ActiveSheet.Name, 5) = "Sheet" Then
ActiveSheet.Columns("B").Delete
End If
End Sub
Or:

Code:
Private Sub Worksheet_Deactivate()
If Left(ActiveSheet.Name, 5) = "Sheet" Then
ActiveSheet.Range("B1").entirecolumn.Delete
End If
End Sub
If you do delete more than one column make sure you work from right to left with deleting the columns like the first set of code. Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

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