Clear data from pivot table

K

Klemen25

Hello all.

Usually when building a pivot table report I throw the data sets in
the pivot table a few times to find the best way to show data.
So I wonder - is there a way to quickly erase all the data sets so the
pivot table is again empty as just being created (so I do not have to
select each data set and remove it?
Macro or some other trick?

The closest I got to the answer was the idea to just create another
pivot table from the original data…but it would be so much easier to
click a button and all the data is cleared from the pivot table.

Thank you as always people!
 
D

Debra Dalgleish

In Excel 2007 there's a Clear command on the PivotTable Options tab of
the Ribbon.
You could use a macro to clear the pivot table, in Excel 2003 or
earlier. This examples clears the pivot table for the active cell.
'====================
Sub ActiveCellClearPivot()

On Error Resume Next

Dim pt As PivotTable
Dim pf As PivotField

Set pt = ActiveCell.PivotTable
For Each pf In pt.VisibleFields
pf.Orientation = xlHidden
Next pf
'pt.RefreshTable

End Sub

'========================
 
K

Klemen25

Great!
Works like a charm.
I had in mind to mention that I use Excel 2003 but it slipped my mind.

Thank you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top