![]() The next few examples show the same ranges as above, after pivoting the table’s Years field from the columns area to the rows area. Pt.PivotFields("Order Date").PivotItems("Feb").DataRange.Select Pt.PivotFields("Years").PivotItems("2004").LabelRange.Select Pt.PivotFields("Years").LabelRange.Select I’ve highlighted the various ranges using the indicated VBA commands. ![]() ![]() In VBA, you can reference a pivot table using this code in a procedure: I’ll illustrate these special ranges using this simple pivot table, which comes from an example formerly available on the Microsoft web site (I can no longer locate it). One important part of this is referencing the various ranges within a pivot table by their special VBA range names (which are actually properties of the Pivot Table object). I thought it would be helpful to show some of the mechanics of programming with pivot tables. These examples included specific procedures, and the emphasis was on the results of the manipulation. I’ve posted several examples of manipulating pivot tables with VBA, for example, Dynamic Chart using Pivot Table and VBA and Update Regular Chart when Pivot Table Updates.
0 Comments
Leave a Reply. |