Solved

Excel 2007 Pivot Chart VBA - Charts Check Boxes

Posted on 2013-11-25
1
564 Views
Last Modified: 2013-12-03
Hello,

I had created a Pivot Table
9 columns
Row Labels with system names
then 8 columns with Averages and Counts

Then I've created Chart

I want to add Check Buttons on chart so that I can uncheck or check and that way manipulate visibility of the 8 comlumns on the chart. Bar chart.

My code that doesnt work well:

Sub Use_Checkboxes_to_Filter_PivotTable1()

Dim PT As PivotTable
Dim varCbxList() As Variant, varItemList() As Variant
Dim i As Long
Set PT = Sheets("ResponseTime-Support Grp").PivotTables("PivotTable1")
On Error Resume Next
varCbxList = Array("Check Box 5", "Check Box 6", "Check Box 7", "Check Box 8", "Check Box 9", "Check Box 10", "Check Box 11", "Check Box 12")
varItemList = Array("Count of Resolved", "Average of QueueTime", "Average of ResWaitTime", "Average of WorkTIme", "Average of RepairTime", "Average of VerifyTime", "Count of Closed", "Average of ServiceTime")

'--Ensure at least one item is checked and visible
   For i = LBound(varCbxList) To UBound(varCbxList)
     If Sheets("ResponseTime-Support Grp").CheckBoxes(varCbxList(i)).Value = xlOn Then
            PT.PivotFields("Count of Resolved").PivotItems(varItemList(i)).Visible = True
            Exit For
        Else
            If i = UBound(varCbxList) Then
                MsgBox "You must have at least one item checked"
                Exit Sub
            End If
        End If
    Next i
    For i = LBound(varCbxList) To UBound(varCbxList)
       If Sheets("ResponseTime-Support Grp").CheckBoxes(varCbxList(i)).Value = xlOff Then
            PT.PivotFields("Count of Resolved").PivotItems(varItemList(i)).Visible = False
        Else
            PT.PivotFields("Count of Resolved").PivotItems(varItemList(i)).Visible = True
        End If
    Next i
    Set PT = Nothing
End Sub


Thanks!
0
Comment
Question by:CABRLU63
1 Comment
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39677267
Hi,

xlOff (-4146) is not an accepted value for CheckBox.Value

it should 0 (No), 1 (Yes) or 2 (Greyed)

Regards
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

863 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

26 Experts available now in Live!

Get 1:1 Help Now