+ Reply to Thread
Results 1 to 6 of 6

VB to add values to Pivot Tables not working.

  1. #1
    Registered User
    Join Date
    06-14-2013
    Location
    Essex, England
    MS-Off Ver
    Excel 2013
    Posts
    21

    Question VB to add values to Pivot Tables not working.

    Please Login or Register  to view this content.
    Hi all,
    Basically I am trying to rebuild pivot tables, which basically means adding back the 'value' field. They were working independently which was why they were written in such a manner, but failed when all together in a single procedure. Yet when I call to each I get errors.. Errors which were not happening when they were run on their own. These were recorded and proved working at the time.. Any advice much appreciated..

    Error appears again and again on following :

    Please Login or Register  to view this content.
    ActiveSheet.PivotTables("Forecast_Master_Cost").AddDataField ActiveSheet. _
    PivotTables("Forecast_Master_Cost").CubeFields( _
    "[Measures].[Sum of Actual Cost]"), "Sum of Actual Cost"
    Please Login or Register  to view this content.

    Whole code...

    Please Login or Register  to view this content.
    Sub Forecast_N1()
    '
    ' Forecast_N1 Macro
    '

    Application.ScreenUpdating = False
    Worksheets("Forecast").Activate
    ActiveSheet.PivotTables("Forecast_Planned_NONGEN").AddDataField ActiveSheet. _
    PivotTables("Forecast_Planned_NONGEN").CubeFields( _
    "[Measures].[Sum of Planned Work Days]"), "Sum of Planned Work Days"
    With ActiveSheet.PivotTables("Forecast_Planned_NONGEN").PivotFields( _
    "[Measures].[Sum of Planned Work Days]")
    .NumberFormat = "0.00"
    End With
    Call Forecast_N3
    End Sub

    Sub Forecast_N2()
    '
    ' Forecast_N1 Macro
    '
    Application.ScreenUpdating = False
    Worksheets("Forecast").Activate
    ActiveSheet.PivotTables("Forecast_Planned_GENERIC_ONLY").AddDataField ActiveSheet. _
    PivotTables("Forecast_Planned_GENERIC_ONLY").CubeFields( _
    "[Measures].[Sum of Planned Work Days]"), "Sum of Planned Work Days"
    With ActiveSheet.PivotTables("Forecast_Planned_GENERIC_ONLY").PivotFields( _
    "[Measures].[Sum of Planned Work Days]")
    .NumberFormat = "0.00"
    End With
    Call Forecast_N3
    End Sub

    Sub Forecast_N3()
    '
    ' Forecast_N3 Macro
    '
    Application.ScreenUpdating = False
    Worksheets("Forecast").Activate
    ActiveSheet.PivotTables("Forecast_Base_NOGENERICS").AddDataField ActiveSheet. _
    PivotTables("Forecast_Base_NOGENERICS").CubeFields( _
    "[Measures].[Sum of BaseCapacity Days]"), "Sum of BaseCapacity Days"
    With ActiveSheet.PivotTables("Forecast_Base_NOGENERICS").PivotFields( _
    "[Measures].[Sum of BaseCapacity Days]")
    .Caption = "Base Capacity Days"
    .NumberFormat = "#,##0.00"
    End With
    Call Forecast_N4
    End Sub
    Please Login or Register  to view this content.
    [/CODE]
    Last edited by Fotis1991; 05-21-2015 at 03:58 AM. Reason: CODE TAGS ADDED

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: VB to add values to Pivot Tables not working.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Registered User
    Join Date
    06-14-2013
    Location
    Essex, England
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: VB to add values to Pivot Tables not working.

    Apologies - done..


    -CL

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VB to add values to Pivot Tables not working.

    Or not...

  5. #5
    Registered User
    Join Date
    06-14-2013
    Location
    Essex, England
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: VB to add values to Pivot Tables not working.

    It has the [code] tag when I edit it..

    If it has not worked Mr Mod, please delete the thread!


    Thanks,

    -CL

  6. #6
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: VB to add values to Pivot Tables not working.

    I added code tags for you. Pls remember to add code tags next time... The point is not to delete your thread(as you are here asking for help) but everyone has to comply with the rules.

+ 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. Working with Pivot Tables
    By kats9137 in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 12-10-2011, 11:14 AM
  2. Excel 2007 : Working with Pivot Tables in Excel 2007
    By GrahamButler1970 in forum Excel General
    Replies: 1
    Last Post: 03-04-2011, 08:13 AM
  3. Working with Pivot tables with % change
    By Charlie in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-28-2006, 11:25 AM
  4. [SOLVED] Working with Pivot Tables
    By M.Siler in forum Excel General
    Replies: 2
    Last Post: 06-27-2005, 10:05 AM
  5. [SOLVED] Working with Pivot Tables
    By M.Siler in forum Excel General
    Replies: 2
    Last Post: 06-27-2005, 10:05 AM

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