+ Reply to Thread
Results 1 to 4 of 4

Deactive Pivotupdate while updating Filter VBA

  1. #1
    Registered User
    Join Date
    07-22-2013
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2003
    Posts
    11

    Deactive Pivotupdate while updating Filter VBA

    Hey guys,

    So I am working on creating a dashboard in excel, using several different pivottables with external sources.
    Currently I am trying to create an update buttom that updates all the external pivottables (which have been named for simplicity) and then updating the pivot's on those pivots after.

    During this update I want my filter on the external PivotTables to be updated according to todays date. It works like this: If we take today as an example, we are in 2017, quarter 3, month 9, week 39. Since the database is giving me numbers that are not comparable for the week we are in, I only need this years date selected.
    I have written this in the Pivot and the filtering itself works fine.

    My problem occurs during this filtering process, as the OLAP query runs several time making the update process EXTREMELY slow. When I select the filter from clicking on the Pivot Table and selecting the weeks to be included it only runs the OLAP query once, and thus it only takes around 15-20 seconds. But when I do (exactly) the same with my VBA macro it runs the OLAP query several times, and the update takes more than a minute. Having to do this for 6 pivots takes up too much time.

    Is there anyway I can make it stop updating the pivot untill the filter has been selected, or in any other way stop it from running the OLAP query several times?

    Here is the code I have made. Be aware, it is the first thing I've done, so some of it could probably have done simpler:

    Please Login or Register  to view this content.
    It is the last part that does the filtering. It does it the same way as when I recorded the macro from doing it myself, hence, it shouldnt take longer than during it manually.

    This is part of a longer code that creates the arrays from today's date, and that itself works perfect. The thing that slows it down is this pivotFields(...).VisibleitemsList that creates several OLAP query.

    Any ideas on how to speed this filtering up?

    Best
    Anders

  2. #2
    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: Deactive Pivotupdate while updating Filter VBA

    Hi,

    Perhaps set the ManualUpdate property of the pivot table to True before you change the filters and then back to False at the end, and disable events as well using Application.Enableevents = False (remembering to set back to True at the end of course).
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Registered User
    Join Date
    07-22-2013
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Deactive Pivotupdate while updating Filter VBA

    Hi xlnitwit,

    Sorry for the slow reply.
    It appears as though your suggested command was enough to delay the update. Much appreciated!

    Have a great day.

    Best,
    Anders

  4. #4
    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: Deactive Pivotupdate while updating Filter VBA

    You're welcome.

    Please remember to mark the thread Solved using the Thread Tools link at the top.

+ 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. Automatically updating Advance Filter
    By masaindia in forum Excel General
    Replies: 1
    Last Post: 04-28-2017, 05:17 AM
  2. Deactive msgbox from other macroes when clicking "master" macro
    By StefaniaLa in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-24-2016, 07:53 AM
  3. Advanced Filter Automatic Updating
    By s.cruff in forum Excel General
    Replies: 1
    Last Post: 03-11-2014, 03:01 PM
  4. Deactivate links when workbook saved by different name
    By JamesT1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-01-2013, 03:50 AM
  5. Automatically updating forumlas when using a filter
    By stanja in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-02-2013, 05:27 AM
  6. Filter not automatically updating multiple columns - need help please
    By pdt7361 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-21-2012, 02:10 PM
  7. auto filter's total are not updating
    By ggremel in forum Excel General
    Replies: 1
    Last Post: 11-23-2010, 01:43 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