+ Reply to Thread
Results 1 to 2 of 2

Apply a procedure only to specific pivot tables (MDX)

  1. #1
    Registered User
    Join Date
    01-16-2014
    Location
    abu dhabi
    MS-Off Ver
    Excel 2003
    Posts
    2

    Apply a procedure only to specific pivot tables (MDX)

    Dear all,

    I have been trying to create a macro that:
    1) opens all my excel files in a folder
    2) adds a new connection to each file
    3) for each pivot table (of each sheet in each file) that is linked to my data cube, I instruct the macro to replace the existing connection and replace it with the new connection I added (see point 2).
    I am only interested in the pivots that are connected to the cube, and therefore if a pivot is connected to an SQL query or if a pivot is sourced from another table then I do not want to touch them.

    In order to identify the pivots that are sourced from the cube, I used one of their properties: MDX, so I instructed

    If Left(CrntPvtTbl.MDX, 6) = "SELECT" Then
    CrntPvtTbl.ChangeConnection crntfl.Connections("MynewConnection")

    I though by doing this I would exclude all other pivots (which is what I want).
    However, it is not working. I get an error every time the code reaches a table that is sourced from another table (a range).

    So my question to you guys is:
    is there a better way of identifying those pivots that are linked to a cube and exclude the other ones?

    What I have tried to do is to set an object as MDX and when that object isnothing it means that it is not sourced from cube so ignore it. This did not work.
    I have also tried to replace If Left(CrntPvtTbl.MDX, 6) = "SELECT" Then

    with

    If Left(CrntCnctn.OLEDBConnection.Connection, Len("OLEDB;Provider=MSOLAP")) = "OLEDB;Provider=MSOLAP" Then

    but it did not work. An error I often get is 1004

    Thank you in advance!

  2. #2
    Registered User
    Join Date
    01-16-2014
    Location
    abu dhabi
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Apply a procedure only to specific pivot tables (MDX)

    Hello all -
    just to let you know this question has been answered here: http://www.mrexcel.com/forum/excel-q...ml#post3690974


    all the best

+ 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. Changing specific pivot tables at once Excel 2010
    By LeeJames92 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 09-20-2013, 05:52 AM
  2. Advanced VBA - add-in to apply/unapply procedure names as constants?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 29
    Last Post: 05-13-2013, 07:01 AM
  3. [SOLVED] How To Set Up Multiple Pivot Tables By Specific Dates?
    By ScotyB in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2012, 05:57 AM
  4. [SOLVED] How does the term 'pivot' apply to Excel's Pivot tables and Pivot.
    By stvermont in forum Excel General
    Replies: 1
    Last Post: 02-18-2005, 10:06 AM
  5. Excel Pivot Tables Show and Hide Specific Items
    By Ruth in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-11-2005, 11:02 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