View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
ryguy7272 ryguy7272 is offline
external usenet poster
 
Posts: 2,836
Default Delete Blank Rows when Pivot Table included on sheet

You can't delete or add rows to a Pivot Table. Delete all blanks before you
build the Pivot Table (I assume you are building the table with code, right).
Or, in your Pivot Table you will see some down arrows, click any one and if
there are blanks in there you'll see (blank) with a small check box in front
of it. Un-check the box and that will eliminate the blanks. Then, turn on
the macro recorder and do the same thing and turn off the recorder. Look at
the resulting code. Copy/paste that code into the appropriate place in your
code-sequence, and Excel will automatically do this for you next time
(eliminate blanks). You may have to play with the positioning of the code a
bit to get it working right, but just keep at it and you'll get it.

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Joyce" wrote:

Hi,

I've run code to delete blank rows which works fine. That is, it works fine
until I'm deleting blank rows on a sheet which also contains a few pivot
tables.

I encounter an error message regarding not being able to change pivot table.

Here is my code: Thanks!

Dim x As Long

With ActiveSheet
For x = .Cells.SpecialCells(xlCellTypeLastCell).Row _
To 1 Step -1

If WorksheetFunction.CountA(.Rows(x)) = 0 Then
ActiveSheet.Rows(x).Delete
End If

Next
End With