It seems like the excel application scope is being closed before excel refresh is complete. For now to confirm may be you can try giving a wait time in vba code
Application.OnTime Now + TimeValue(“00:00:05”), “DelayedProcedure”
or may be you can use visible property or keep excel open, so that you can see what is happening.
But this has never happened to me, normally the scope should be active till all actions are complete. If required you could add wait till refresh or whatever action is there in your code to complete using vba itself.
And in my experience it is always better to disable alerts or pop ups and use proper exception handling in vba.
also in your case i would suggest to first identify why that error is happening, if the refresh is not complete it would give wrong results right. As i mentioned to identify you can either add wait in vba or keep excel open/visible from UiPath