+ Reply to Thread
Results 1 to 7 of 7

modify calculated field (pivot) with macro

  1. #1
    Forum Contributor
    Join Date
    07-13-2017
    Location
    Hong Kong
    MS-Off Ver
    MS Office 365
    Posts
    481

    modify calculated field (pivot) with macro

    Hi all,

    How can I modify the formula of a calculated field by using a macro? I have about 20 calculated fields that need to be changed, which is quite time consuming.

    The formula of the calculated field "AUR" in the pivot "Last Year" would be something like this:

    Please Login or Register  to view this content.
    and would need to be changed to:

    Please Login or Register  to view this content.
    Can this be done with code?

  2. #2
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: modify calculated field (pivot) with macro

    If I record a macro changing the field title I get something like this;
    Please Login or Register  to view this content.
    Don't know if that helps or not.

  3. #3
    Forum Contributor
    Join Date
    07-13-2017
    Location
    Hong Kong
    MS-Off Ver
    MS Office 365
    Posts
    481

    Re: modify calculated field (pivot) with macro

    That seems to work indeed! Do you also happen to know how to change the calculated field's name not just it's formula? It only let's me add a new calculated field, but not change its name...

  4. #4
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: modify calculated field (pivot) with macro

    I'm not sure if you can. You may need to delete it and re-add with the new name.

  5. #5
    Forum Contributor
    Join Date
    07-13-2017
    Location
    Hong Kong
    MS-Off Ver
    MS Office 365
    Posts
    481

    Re: modify calculated field (pivot) with macro

    which is exactly what creates so much work...

  6. #6
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: modify calculated field (pivot) with macro

    Record a macro of the delete and the add and see if that helps you.

    If this is only a one-off then you might be quicker just spending 20 minutes doing it the old-fashioned way.

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: modify calculated field (pivot) with macro

    Why do you need to rename it rather than just changing its caption?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

+ 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 based on Running Total Field
    By EvolvingMonkey in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 09-07-2016, 06:27 AM
  2. Replies: 0
    Last Post: 08-15-2016, 02:07 PM
  3. [SOLVED] A pivot table field calculated using other field values as fields?
    By chrisf78 in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 05-07-2015, 03:08 AM
  4. [SOLVED] Referring to a Sub-Field on Calculated Field Pivot Table Column?
    By figo12 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-27-2014, 02:02 PM
  5. Replies: 1
    Last Post: 12-21-2012, 05:40 AM
  6. Replies: 0
    Last Post: 06-26-2012, 09:06 PM
  7. [SOLVED] pivot table formulas for calculated field or calculated item
    By Vicky in forum Excel General
    Replies: 3
    Last Post: 06-06-2006, 12:10 AM

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