+ Reply to Thread
Results 1 to 2 of 2

Pivot Table Question - Using Calculations

Hybrid View

  1. #1
    Forum Contributor Tarball's Avatar
    Join Date
    04-21-2007
    Location
    Atlanta, GA
    Posts
    166

    Pivot Table Question - Using Calculations

    Given a simple Pivot table below. Dealer, Sales, and Units are in my source data. How can I programmatically build the Average Price colum in my Pivot Table. Average Price=Sales/Units

    Dealer     Sales     Units     Average Price
    Me           10         5             2
    You         100        25           4
    Thanks for the help.

    Tarball

  2. #2
    Forum Contributor Tarball's Avatar
    Join Date
    04-21-2007
    Location
    Atlanta, GA
    Posts
    166
    Well I figured it out myself! Best way to learn is to read and do a little trial and error. For those of you who read this thread and have the same question...here is how to do it.

       Dim PT As PivotTable
    
       . . .
    
       'Build Your Pivot Table
    
        With PT
          .CalculatedFields.Add "MY CUSTOM FIELD NAME", "=SALES/UNITS"
          .PivotFields("MY CUSTOM FIELD NAME").Orientation = xlDataField
          .PivotFields("MY CUSTOM FIELD NAME").NumberFormat = "$#,##0.00"
        End With
    Enjoy
    Last edited by Tarball; 06-12-2007 at 11:01 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1