Solved

All the False values in recorded Pivot table

Posted on 2014-02-17
4
343 Views
Last Modified: 2014-02-25
Do I really need all these false values on a pivot table created with the recorder?

    ActiveSheet.PivotTables("PivotTable10").AddDataField ActiveSheet.PivotTables( _
        "PivotTable10").PivotFields("Oper. Qty"), "Sum of Oper. Qty", xlSum
    Range("B6").Select
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Order Number").Subtotals _
        = Array(False, False, False, False, False, False, False, False, False, False, False, False _
        )
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Category  ").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("CAT_ORD").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Loc   ").Subtotals = Array _
        (False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Product ").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields( _
        "Product Short Description               ").Subtotals = Array(False, False, False _
        , False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Basic Matl").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Resource        "). _
        Subtotals = Array(False, False, False, False, False, False, False, False, False, False, _
        False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields( _
        "Short Description               ").Subtotals = Array(False, False, False, False, _
        False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Start Date").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Start Time").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("PlanShip St").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Del Plant Desc"). _
        Subtotals = Array(False, False, False, False, False, False, False, False, False, False, _
        False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Usage").Subtotals = Array( _
        False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("MAXMadDate").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("End Date  ").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("RecMADDate").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Reason Cd").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Msg Text").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Seat Color 1").Subtotals _
        = Array(False, False, False, False, False, False, False, False, False, False, False, False _
        )
    ActiveSheet.PivotTables("PivotTable10").PivotFields("End Time").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("TimeZone").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Oper. Qty").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("  Op.Duratn").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("  Op.Duratn2").Subtotals _
        = Array(False, False, False, False, False, False, False, False, False, False, False, False _
        )
    ActiveSheet.PivotTables("PivotTable10").PivotFields("   RemOpDur").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Dealloc.").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Released").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Fixed").Subtotals = Array( _
        False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Started").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Part.Conf.").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("Final Con.").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("PegReqOrNo").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("SO").Subtotals = Array( _
        False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("SOLN").Subtotals = Array( _
        False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").PivotFields("SOSOLN").Subtotals = Array _
        (False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable10").RowAxisLayout xlTabularRow

Open in new window

0
Comment
Question by:RWayneH
  • 2
4 Comments
 
LVL 12

Expert Comment

by:Harry Lee
ID: 39866218
RWayneH,

Do you mind to upload your data and pivot table? It's extremely hard to read these codes like this.

You probably don't need all these, but I need to take a look in the actual data to tell.
0
 
LVL 81

Accepted Solution

by:
byundt earned 500 total points
ID: 39866232
Yes, you need all the False, but you can simplify your code to this:
Sub PT()
Dim pf As Variant
With ActiveSheet.PivotTables("PivotTable10")
    .AddDataField .PivotFields("Oper. Qty"), "Sum of Oper. Qty", xlSum
    
    For Each pf In Array("Order Number", "Category  ", "CAT_ORD", "Loc   ", "Product ", "Product Short Description               ", _
            "Basic Matl", "Resource        ", "Short Description               ", "Start Date", "Start Time", "PlanShip St", _
            "Del Plant Desc", "Usage", "MAXMadDate", "End Date  ", "RecMADDate", "Reason Cd", "Msg Text", "Seat Color 1", _
            "End Time", "TimeZone", "Oper. Qty", "  Op.Duratn", "  Op.Duratn2", "   RemOpDur", "Dealloc.", "Released", _
            "Fixed", "Started", "Part.Conf.", "Final Con.", "PegReqOrNo", "SO", "SOLN", "SOSOLN")
        .PivotFields(pf).Subtotals = Array(False, False, False, False, False, False, False, False, False, False, False, False)
    Next
    .RowAxisLayout xlTabularRow
End With
End Sub

Open in new window

0
 
LVL 12

Expert Comment

by:Harry Lee
ID: 39866237
Good eye Brad!

The code makes me feel dizzy.
0
 

Author Closing Comment

by:RWayneH
ID: 39887665
EXCELlent -R-
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

770 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