+ Reply to Thread
Results 1 to 1 of 1

VBA to position calculated values in pivot table

  1. #1
    Registered User
    Join Date
    11-03-2020
    Location
    London
    MS-Off Ver
    2016
    Posts
    29

    VBA to position calculated values in pivot table

    Hi,

    Super VBA beginner here and need some basic help.

    I am using VBA to create a pivot table and I need to calculate two values. I have successfully written the code to calculate the values but I need help to order the calculations into different columns because the code tries to overwrite the first calculation.

    I need the pivot table to be structured like in the attached excel sheet.


    Current code:

    Sub Calculate_VAT()

    With ActiveSheet.PivotTables("XXX Sales and VAT")
    .CalculatedFields.Add "VAT", "='Enterprise XXX Vat Report Vat on 5pct'+'Enterprise XXX Vat Report Vat on 20pct'", True
    .PivotFields("VAT").Orientation = xlDataField
    End With

    End Sub


    Sub Calculate_ServiceFeeIncVAT()

    With ActiveSheet.PivotTables("XXXX Sales and VAT")
    .CalculatedFields.Add "Service Fee", "='Enterprise XXX Vat Report Service Fee Before Discount Ex Vat' + 'Enterprise XXX Vat Report Vat on Service Fee'", True
    .PivotFields("Service Fee").Orientation = xlDataField
    End With
    End Sub
    Attached Files Attached Files
    Last edited by Sahil1991SP; 08-25-2021 at 05:27 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Pivot table calculated Field from count of values
    By 99problems in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-08-2015, 05:44 PM
  2. [SOLVED] Calculated Formula Pivot Table Values - DSO
    By jmcconville18 in forum Excel General
    Replies: 4
    Last Post: 06-26-2014, 11:41 AM
  3. Pivot Table:delete zero values when using calculated objects
    By Serge 007 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 06-05-2013, 02:47 PM
  4. Calulating a Ratio from Calculated Values in Pivot Table
    By marshymell0 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-07-2013, 01:21 PM
  5. How to rank values from a calculated column in a pivot table
    By Algonquin Dude in forum Excel General
    Replies: 0
    Last Post: 11-30-2011, 09:50 PM
  6. assigning a position in a pivot table for a calculated item
    By jsmath22 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-18-2009, 03:58 PM
  7. Replies: 0
    Last Post: 10-14-2009, 03:27 PM

Tags for this Thread

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