Creating A Report Showing Revenue By Product - Amazon VBA Manual

Using vba to create pivot tables
Table of Contents

Advertisement

246
Chapter 11
Listing 11.2 Continued
WSD.Activate
Range("R1").Select
End Sub
The preceding code creates the pivot table. It then copies the results as values and pastes
them as values in R10:V13. Figure 11.6 shows an intermediate result just before the original
pivot table is cleared.
So far, this chapter has walked you through building the simplest of pivot table reports.
Pivot tables offer far more flexibility. Read on for more complex reporting examples.

Creating a Report Showing Revenue by Product

A typical report might provide a list of markets by product with revenue by year. This
report could be given to product line managers to show them which markets are selling
well. In this example, you want to show the markets in descending order by revenue with
years going across the columns. A sample report is shown in Figure 11.7.
Figure 11.7
11
A typical request is to
take transactional data
and produce a summary
by product for product
line managers.You can
use a pivot table to get
90% of this report and
then a little formatting
to finish it.
The key to producing this data quickly is to use a pivot table. Although pivot tables are
incredible for summarizing data, they are quirky and their presentation is downright ugly.
The final result is rarely formatted in a manner that is acceptable to line managers. There is
not a good way to insert page breaks between each product in the pivot table.
To create this report, start with a pivot table that has Product and Market as row fields,
Invoice Date grouped by year as a column field, and Sum of Revenue as the data field.
Figure 11.8 shows the default pivot table created with these settings.
Using VBA to Create Pivot Tables

Advertisement

Table of Contents
loading

Table of Contents