Question : Wait Till Queries Have Refreshed

I'm trying to execute the code below but I'm getting an error that says the operation cannot be done because the data is refreshing in the background.  How do I get it to wait until the queries have refreshed?  I already have "enable background refresh" selected for all the data connections.
Code Snippet:
1:
2:
3:
4:
5:
For Each wks In ActiveWorkbook.Worksheets
   For Each ObjList In wks.ListObjects
      ObjList.Unlist
   Next ObjList
 Next wks

Answer : Wait Till Queries Have Refreshed

Try
1:
2:
3:
4:
5:
6:
For Each wks In ActiveWorkbook.Worksheets 
   For Each ObjList In wks.ListObjects 
      objlist.querytable.refresh False
      ObjList.Unlist 
   Next ObjList 
 Next wks
Random Solutions  
 
programming4us programming4us