Solved

Selecting all the check boxes excluding #N/A and Blank under Row labels in a pivot table

Posted on 2014-12-22
5
384 Views
Last Modified: 2015-01-06
Hi,

My source data has empty cells and #N/A.  When I Pivot Table this data - the Pivot Table shows "(blank)" for the empty cells and #N/A under Row labels. I would not want to manually filter and uncheck (blank) and #N/A every time.

Let me know if anyone have a VBA code to perform this. And also it would of great help if you have the code to check all the boxes or check only few boxes as desired under row labels in the pivot table.

So ultimately i need a VBA code that will:
1) Automatically hide any row that contains the words "(blank)"/ "N/A" under Row labels.
2) Automatically Check all the boxes under Row labels.
3) Automatically Check only few boxes under Row labels.

Thanks,
Ganesh
0
Comment
Question by:Ganesh Vijaykumar
  • 3
  • 2
5 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
Comment Utility
Hi,

Could you send a dummy example?

With ActiveSheet.PivotTables("PivotTable1").PivotFields("MyPivotField")
        .PivotItems("(blank)").Visible = False
        .PivotItems("#N/A").Visible = False
End With


Regards
0
 

Author Comment

by:Ganesh Vijaykumar
Comment Utility
Hi Rgonzo1971,

Thanks for your response!

Hope you had a great Christmas! Could not respond you immediately as i was on holiday.

The above code worked for me thanks a lot again. But it only for worked to deselect #N/A / Blank under the pivot table.  

As i mentioned in the above question (Point number 2) i need code for
2) Automatically Check all the boxes under Row labels.

I am working on a VB scripted template where the data changes every week. The problem i am facing is every time data changes only few items will checked/selected under row labels in the pivot table. I have to manually check all the boxes every time. I have attached the word document for your reference.

It would of great help if you could help me with the code which automatically selects all the check boxes.

Will be awaiting your positive response!

Thanks,
G
0
 

Author Comment

by:Ganesh Vijaykumar
Comment Utility
0
 
LVL 48

Expert Comment

by:Rgonzo1971
Comment Utility
then try

For each pvtItm in ActiveSheet.PivotTables("PivotTable1").PivotFields("MyPivotField").PivotItems
        pvtItm.Visible = True
Next
0
 

Author Comment

by:Ganesh Vijaykumar
Comment Utility
Hi Rgonzo1971,

I used the above code but still unsuccessful in automatically selecting all the check boxes. I am relatively new to VBA coding, may be I am not placing the code at the right place.

It would of great help if you could help me editing the below mentioned code, in such a way that script will automatically selects all the check boxes under row labels in pivot table.


Below is the code I am using to fetch the data from one excel sheet to another and refreshing pivot table.

Sub PVDetails_DataFetch()

Dim filespec As Variant
Dim filename As String

    MsgBox "Please select the pvdetails Week File"

    filespec = Application.GetOpenFilename("Excel-files,*.xlsx", _
        1, "Select the PV Details File ", , False)
         If TypeName(filespec) = "Boolean" Then Exit Sub
    Workbooks.Open (filespec)
    Sheets("PV DETAILS LAST WK-S").Select

    Range("A3").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
   
       
    Windows("PV Template Automated Template.xlsm").Activate
    Sheets("PV DETAILS LAST WK-S-RD").Select
    Range("B3").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False

   
    Workbooks.Open (filespec)
    Sheets("PV DETAILS THIS WK-S").Select

    Range("A3").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy

       
    Windows("PV Template Automated Template.xlsm").Activate
    Sheets("PV DETAILS THIS WK-S -RD").Select
    Range("B3").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
   
    Sheets("PV DETAILS THIS WK-S -RD-PIV").Select
    Range("B5").Select
    ActiveSheet.PivotTables("PivotTable3").PivotCache.Refresh
   
    Sheets("PV DETAILS THIS WK-S -RD-PIV").Select
    Range("B6").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Sheets("PV DETAILS THIS WK-S").Select
    Range("A2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
       
    Sheets("PV DETAILS THIS WK-S -RD-PIV").Select
    Range("C6").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Sheets("PV DETAILS THIS WK-S").Select
    Range("M2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
       
    Sheets("PV DETAILS LAST WK-S-PIV").Select
    Range("B5").Select
    ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
   
    Sheets("PV DETAILS LAST WK-S-PIV").Select
    Range("B6").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Sheets("PV DETAILS LAST WK-S").Select
    Range("A2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
       
    Sheets("PV DETAILS LAST WK-S-PIV").Select
    Range("C6").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Sheets("PV DETAILS LAST WK-S").Select
    Range("M2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False


    Sheets("Macro").Select
   
   
End Sub


Please do let me know if you need any additional information!

Thanks,
G
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now