+ Reply to Thread
Results 1 to 14 of 14

Refreshing PowerQuery Tables on a Protected Sheet

  1. #1
    Registered User
    Join Date
    09-05-2016
    Location
    Scotland
    MS-Off Ver
    2013
    Posts
    11

    Refreshing PowerQuery Tables on a Protected Sheet

    I have a workbook with 6 PowerQuery tables, and one PowerQuery table to append the six into the one table.

    The six are on hidden, unprotected sheets. However, I have the appended table on protected sheet.

    When I have the protection off and I run my refresh macro the table updates fine. However, when the sheet is protected the table does not update.

    My macro is set to unprotect the sheet, refresh, and then reprotect. However, what is is doing is; unprotecting, refreshing, and then reporotecting before the refresh is done.

    I've tried adding in a wait before reprotecting, but this didn't help.

    It seems my problem is that after the macro has finished running, the PowerQuery tables are still updating. How can I unprotect the sheet, refresh the tables, wait until the refresh is complete, and then reprotect the sheet?

  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: Refreshing PowerQuery Tables on a Protected Sheet

    Hi,

    You probably just need to specify the Backgroundquery:=False argument when refreshing the table.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Registered User
    Join Date
    09-05-2016
    Location
    Scotland
    MS-Off Ver
    2013
    Posts
    11

    Re: Refreshing PowerQuery Tables on a Protected Sheet

    I have the below as my macro to refresh, where/how do I specify the Backgroundquery:=False argument?

    Please Login or Register  to view this content.

  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: Refreshing PowerQuery Tables on a Protected Sheet

    You can't do it with RefreshAll. You would need to loop through the individual tables and refresh each one. You can also set the relevant property of the table instead in the Query pane, and then RefreshAll should work.
    Last edited by xlnitwit; 10-18-2017 at 11:16 AM.

  5. #5
    Registered User
    Join Date
    09-05-2016
    Location
    Scotland
    MS-Off Ver
    2013
    Posts
    11

    Re: Refreshing PowerQuery Tables on a Protected Sheet

    Not sure how I'd do that to be honest. This is my first time using PowerQuery – only downloaded the add-on for 2010 yesterday.

    Is this the Query pane you mean? After I run my macro it says that the one on the protected sheet didn't download.

    Query.PNG

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Refreshing PowerQuery Tables on a Protected Sheet

    This is the code I use to refresh PowerQuery connections.

    Please Login or Register  to view this content.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  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: Refreshing PowerQuery Tables on a Protected Sheet

    If you right-click that query and choose Properties, you should be able to turn off the Background query option and then run your code.

  8. #8
    Registered User
    Join Date
    09-05-2016
    Location
    Scotland
    MS-Off Ver
    2013
    Posts
    11

    Re: Refreshing PowerQuery Tables on a Protected Sheet

    The only options i get in properties are: Name, Description, and then a check box for Fast Data Load.

  9. #9
    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: Refreshing PowerQuery Tables on a Protected Sheet

    Apologies, it looks as though that was added in later versions. In 2010, go to Data tab and connections and edit the properties there. Or use the code that CK76 provided above.

  10. #10
    Registered User
    Join Date
    09-05-2016
    Location
    Scotland
    MS-Off Ver
    2013
    Posts
    11

    Re: Refreshing PowerQuery Tables on a Protected Sheet

    Still no joy unfortunately.

    I'm now thinking I can do it with 4 macros:
    1. unprotect the sheet and refresh
    2. wait until refresh is done (either a time delay, or ideally something to say that the refresh is now finished)
    3. protect the sheet
    4. run macros 1, then 2, then 3

  11. #11
    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: Refreshing PowerQuery Tables on a Protected Sheet

    No joy with what? I've just verified that the option is there in 2010, and CK76's code looks like it should also work.

  12. #12
    Registered User
    Join Date
    09-05-2016
    Location
    Scotland
    MS-Off Ver
    2013
    Posts
    11

    Re: Refreshing PowerQuery Tables on a Protected Sheet

    The option was there, but it still resulted in the the download not being complete.

    I missed CK76's code. I don't understand it. is the "Query -" part supposed to be the name of the table?

  13. #13
    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: Refreshing PowerQuery Tables on a Protected Sheet

    No, it's part of the name of the connection- i.e. what you see in the Connections list on the Data tab.

  14. #14
    Registered User
    Join Date
    09-05-2016
    Location
    Scotland
    MS-Off Ver
    2013
    Posts
    11

    Re: Refreshing PowerQuery Tables on a Protected Sheet

    Got it working.

    Had to make all the table not refresh in the background, and then add in a DoEvents before reprotecting the sheet.

    Realised that I can refresh the main, appended table, without having to do all the ones on the hidden sheets. It still pulls through the correct data. This basically just cuts the time taken in half.

    Please Login or Register  to view this content.
    Thanks for your help guys!

+ 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. Replies: 0
    Last Post: 07-15-2017, 01:50 PM
  2. excel tables with dropdowns not updating on protected sheet
    By tsiguy96 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 12-23-2014, 09:33 AM
  3. Protected Sheet - Tables Problem
    By lyla22 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2014, 08:14 PM
  4. enable OLAP pivot tables in protected sheet
    By sanel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2014, 11:58 AM
  5. Dynamic ranges (tables) not working on a protected sheet
    By Excel_vba in forum Excel General
    Replies: 1
    Last Post: 09-11-2013, 05:26 PM
  6. Refreshing radio button to previous state after deselection on a protected sheet
    By alamar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-11-2013, 10:48 AM
  7. How?: Auto Expansion of Tables in Protected Sheet
    By Safadinhu in forum Excel General
    Replies: 0
    Last Post: 05-26-2010, 01:33 PM

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