title: VBA: How to give Excel time to calculate before jumping into the next command?
body: <p>I am using Bloomberg's BDP formula to pull prices, which generally takes about 1-4 seconds. However, VBA runs the next line of codes before the price pull has been completed, resulting in errors. I am wondering if there is a way to tell Excel to take 5 seconds to run:</p>
  
  <p>Application.Run "RefreshAllStaticData"</p>
  
  <p>The complete code is: </p>
  
  <pre><code>Sub update()
  
  Application.Run "RefreshAllStaticData"
  
  Worksheets("BB").Range("B2:G1000").Copy
  Worksheets("Upload").Range("B2").PasteSpecial Paste:=xlPasteValues
  
  ActiveWorkbook.Save
  ActiveWorkbook.Close
  
  End Sub
  </code></pre>