+ Reply to Thread
Results 1 to 2 of 2

piviot table

  1. #1
    hshayh0rn
    Guest

    piviot table

    I have a piviot table that I inherited and to be honest I'm not very Excel
    savy just yet. I have a sheet within the workbook that I need to run a macro
    on but when I run the macro the entire workbook recalculates each time a
    value on this one sheet is changed and this worksheet could possibly have
    1000+ cells that need to be changed. This causes a HUGE slowdown of this
    macro. Here is the code that I "think" might be causing me the issue. I need
    to somehow exclude this one worksheet from the automatic reclaulation that
    the workbook is doing. I do not want to turn the auto-calculation for this
    workoff off.

    Sub ClearNoDataItems()
    Dim pt As PivotTable
    Dim PF As PivotField
    Dim PI As PivotItem
    Dim PItems As PivotItems
    'Set pt = Selection.PivotTables(1)
    For Each pt In ActiveSheet.PivotTables
    pt.RefreshTable
    For Each PF In pt.PivotFields
    Set PItems = PF.PivotItems
    For Each PI In PItems
    If PI.RecordCount = 0 And PI.Name <> "(blank)" Then
    PI.Delete
    Else
    End If
    Next PI
    Next PF
    Next pt
    End Sub

    Any ideas?

  2. #2
    hshayh0rn
    Guest

    RE: piviot table

    Please ignore this post. I figured out the code I need.

    "hshayh0rn" wrote:

    > I have a piviot table that I inherited and to be honest I'm not very Excel
    > savy just yet. I have a sheet within the workbook that I need to run a macro
    > on but when I run the macro the entire workbook recalculates each time a
    > value on this one sheet is changed and this worksheet could possibly have
    > 1000+ cells that need to be changed. This causes a HUGE slowdown of this
    > macro. Here is the code that I "think" might be causing me the issue. I need
    > to somehow exclude this one worksheet from the automatic reclaulation that
    > the workbook is doing. I do not want to turn the auto-calculation for this
    > workoff off.
    >
    > Sub ClearNoDataItems()
    > Dim pt As PivotTable
    > Dim PF As PivotField
    > Dim PI As PivotItem
    > Dim PItems As PivotItems
    > 'Set pt = Selection.PivotTables(1)
    > For Each pt In ActiveSheet.PivotTables
    > pt.RefreshTable
    > For Each PF In pt.PivotFields
    > Set PItems = PF.PivotItems
    > For Each PI In PItems
    > If PI.RecordCount = 0 And PI.Name <> "(blank)" Then
    > PI.Delete
    > Else
    > End If
    > Next PI
    > Next PF
    > Next pt
    > End Sub
    >
    > Any ideas?


+ 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