Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Every time I create a pivot table (available for all Excel versions) I get one or several blank fields. How can I get rid of them?

One workaround I used was to select the blank field, right click | Filter | Hide Selected Items. This can solve my problem but I need to do it manually... Is there a way to automatically hide/exclude the blanks?

share|improve this question
up vote 1 down vote accepted

When selecting the cells to create the Pivot Table from, don't select any blank rows or columns.


Here's what I came up with in VBA:

Private Sub CommandButton1_Click()

Dim pt As PivotTable
Dim pi As PivotItem

Set pt = ActiveSheet.PivotTables("PivotTable2")

For Each pi In pt.PivotFields("B").PivotItems
    If pi.Value = "(blank)" Then pi.Visible = False
Next pi

End Sub

Where "PivotTable2" is the name of your Pivot Table, and "B" is the name of the Row Field you're trying to eliminate blanks from. You can modify the code to hide other types of fields.

share|improve this answer
Right, but there are some fields that need to be blank (or just there is no value for these fields). I need to find a way to automatically exclude the blanks (data range is already set, only new data is added and then the pivot table is refreshed) – Nicu Zecheru Aug 18 '09 at 16:37

I had this problem. My solution was to create defaults for the cells that would be blank. If it's meant to be text use "Empty" or if it's a figure than input "0".

It's not pretty but it gets you out of the rut and moving on. Otherwise I think you'll always have blanks.

share|improve this answer
you're right, this is a good workaround – Nicu Zecheru Mar 30 '10 at 9:09

This usually happens if you select blank rows or columns in your source data. Usually for me it happens because I've been lazy and selected whole columns instead of just the area with the data in it.

share|improve this answer
I do need all the data in the table. However the columns don't change only new rows are added and then i refresh the pivot table – Nicu Zecheru Aug 18 '09 at 16:36

Use condition formatting to make the blank the writing the same color as the background color. the blank is still there but appears to be gone

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .