Hello - I am writing a loop to copy and paste data from a matrix into a historical time sereis for a backtesting model. The loop works correctly yet the Bloomberg API links to do not refresh. Therefore, the loop continues to copy and paste stale data. I tried to delay the loop but that does not work either. Below is a screen shot of the code. Plus, the loop is very slow so any thoughts about how to speed it up are greatly appreciated.
Sub Generate_Data()
OutputSheet.Range("A2:J" & Rows.Count).ClearContents
OutputSheet.Range("L8") = ""
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Dim EndDate As Date, StartDate As Date, CurrDate As Date
StartDate = Sheet11.Range("B1")
EndDate = Sheet11.Range("B2")
oRow = 2
For CurrDate = EndDate To StartDate - 7 Step -7
Sheet11.Range("B2") = EndDate
Application.CalculateFull
Application.Run "RefreshEntireWorkbook"
Application.Wait (Now + TimeSerial(0, 0, 15))
OutputSheet.Range("A" & oRow) = CurrDate
Sheet1.Range("B20:J20").Copy
OutputSheet.Range("B" & oRow).PasteSpecial xlPasteValues
oRow = oRow + 1
Next
OutputSheet.Range("B:J").HorizontalAlignment = xlCenter
OutputSheet.Range("L8") = "Data Series generated at " & Format(Now, "dd-MMM-yy hh:mm:ss")
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
MsgBox "Data Series Generated Successfully", vbInformation
Exit Sub
Err_H:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Bookmarks