Solved

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

Posted on 2014-12-22
5
414 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 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40516073
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
ID: 40521721
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
ID: 40521723
0
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 40521765
then try

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

Author Comment

by:Ganesh Vijaykumar
ID: 40533356
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This article will show you how to use shortcut menus in the Access run-time environment.
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

914 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

17 Experts available now in Live!

Get 1:1 Help Now