How to determine if filtered pivot table is empty

Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: How to determine if filtered pivot table is empty

  1. #1
    New Member
    Join Date
    Sep 2015
    Posts
    24
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default How to determine if filtered pivot table is empty

     
    How to determine if filtered pivot table is empty by using vba.

  2. #2
    Board Regular
    Join Date
    Jan 2014
    Posts
    472
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: How to determine if filtered pivot table is empty

      
    You could count the cells within the dataset
    Code:
    Sub test()
    Dim pt As PivotTable
    Set pt = ActiveSheet.PivotTables(1)
     
    MsgBox (pt.DataBodyRange.Count > 0)
    End Sub
    This would have to be slightly different if you had grandtotals

    Here's some examples of referencing different pivot ranges:
    Referencing Pivot Table Ranges in VBA - Peltier Tech Blog
    Referencing an Excel Pivot Table Range using VBA
    Last edited by ghrain22; Apr 8th, 2016 at 11:34 AM.

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com