Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

This action will cancel a pending refresh data command

Tags:

excel

vba

While I am trying this code I am getting the error "This action will cancel a pending refresh data command.continue?"

ActiveWorkbook.RefreshAll

Even if I put Application.Wait now() + TimeValue("00:01:20") Excel is not refreshing properly.

like image 777
user2902589 Avatar asked Nov 29 '13 04:11

user2902589


1 Answers

Solution: "Go to the data tab, click connections in the connections group, click on EVERY connection and click properties, un-check the box that says "enable background refresh"." ([email protected] , pcreview, 2013).

This error may be caused by Excel being overloaded but only capable of reporting in this way. After trying all of the suggestions about 'DoEvents', 'WAIT'/SLEEP', 'FOR/NEXT' looping and opening each page to refresh singularly, I found, from PCReview website, that the solution is in the Data Connection properties and not VBA.

Once all background refresh connections have been disabled, the simple 'Activeworkbook.RefreshAll' command will suffice to update the entire workbook; mine was 29 pages large with 5 data connections and 7 SQL data connections.

NB: It was only the SQL data connections which allow the refresh to be disabled.

Hope that this helps with anyone having a headache over this issue as I did.

like image 163
LeonK Avatar answered Oct 23 '22 22:10

LeonK