auto.pilot
Well-known Member
- Joined
- Sep 27, 2007
- Messages
- 734
- Office Version
- 365
- Platform
- Windows
Using XL2007, I have the code below, which simply copies a range of data which has been populated from a data feed. This process is repeated based on line numbers found in column A (several hundred times). It all works, except that the code seems to disable the data feed. No matter how much time I use in the WaitNow line, the data feed does not populate the excel spreadsheet. As such, each of my 300+ results are populated with data from the first line only.
Would appreciate any and all advice to pause the macro or allow the data feed to populate while the macro is running.
Thanks in advance.
jim
Would appreciate any and all advice to pause the macro or allow the data feed to populate while the macro is running.
Thanks in advance.
jim
Code:
Sub CashFlow()
Application.ScreenUpdating = False
Dim Rng As Range, Dn As Range
' Section below sets the range line numbers
Set Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
'section below gets the values calculated in for each scenario, then pastes the results of each
For Each Dn In Rng
Range("D2") = Dn
Application.Wait Now() + TimeValue("00:00:10")
Range("C1:I370").Copy
Range("CCC1").Select
Selection.End(xlToLeft).Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats
Next Dn
Application.CutCopyMode = False
Range("D2").Value = 1
Range("A1").Select
Application.ScreenUpdating = True
End Sub