Download did not complete VBA & Power Query

cknnugget

New Member
Joined
Jun 29, 2020
Messages
44
Office Version
  1. 365
Platform
  1. Windows
Using VBA to update power query I keep running into Query updating issues on protected sheets any Ideas on solutions?

When the sheet is protected, I get "Download did not complete".
The query says "you cannot edit a query that has been loaded to a protected worksheet"

When the sheet is Unprotected, the code runs without issue.

Under Data>Properties, Enable Background refresh is unchecked.

Here is the Code:
Sub Memolookup()
Sheets("Memo Look Up").Unprotect Password:=""
ThisWorkbook.Connections("Query - Memo Lookup").OLEDBConnection.refresh
Range("E4") = Range("B8").Value
Range("E5") = Range("C8").Value
Sheets("Memo Look Up").Protect Password:=""
End Sub
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
That is how sheet protection works,leave out the password statement
VBA Code:
Sub Memolookup()
Sheets("Memo Look Up").Unprotect
ThisWorkbook.Connections("Query - Memo Lookup").OLEDBConnection.refresh
Range("E4") = Range("B8").Value
Range("E5") = Range("C8").Value
Sheets("Memo Look Up").Protect
End Sub
 
Upvote 0
My understanding is when Enable background refresh is unchecked, the query completes before moving to the next line in the VBA code. I have had other sheets where power query was updated without issue on a protected sheet. In this workbook it is protecting it before the query is complete. The password statement has a password, I just removed the password to post on the forum.
 
Upvote 1
Have you tried disabling background refresh ?
That way the code won't continue untile the refresh is completed.
 
Upvote 0
Sorry, I can't offer any more, unless you put in a wait statement for say 30 seconds and see if that helps.
VBA Code:
Application.Wait Now + #0:00:30#
 
Upvote 0

Forum statistics

Threads
1,214,605
Messages
6,120,476
Members
448,967
Latest member
visheshkotha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top