I refresh data (MSQuery) using
ActiveWorkbook.RefreshAll
that's fine. I then add some calculations in the columns to the right and copy the formula down to the last row of data.
Range("U2:AJ2").Copy
Range("U2:AJ" & Range("b65536").End(xlUp).Row).Select
ActiveSheet.Paste
The issue I have is that the spreadsheet has not completed the refresh fully before the copy is executed and I'm getting errors on the spreadsheet.
It works fine when I step through the code, as I wait for the refresh to complete, but not when I fire the macro. I could make this a two stage process but it would be alot neater just to do the whole thing in one.
Any ideas?
ActiveWorkbook.RefreshAll
that's fine. I then add some calculations in the columns to the right and copy the formula down to the last row of data.
Range("U2:AJ2").Copy
Range("U2:AJ" & Range("b65536").End(xlUp).Row).Select
ActiveSheet.Paste
The issue I have is that the spreadsheet has not completed the refresh fully before the copy is executed and I'm getting errors on the spreadsheet.
It works fine when I step through the code, as I wait for the refresh to complete, but not when I fire the macro. I could make this a two stage process but it would be alot neater just to do the whole thing in one.
Any ideas?