I'm downloading historical data on a list of 20 or so stocks with
Excel 2000, using the following steps for each:
1. Select scratch worksheet
2. Cells.Delete
3. Cells(1,1).Select
4. Create the URL for this stock
5. Execute the query
6. Copy data from scratch sheet
The program runs great for the first 10 or so stocks, then Excel
crashes. There's no obvious reason, and the particular stock is not
the problem. (I know, because if that stock is moved up higher in the
list it runs fine.)
At first the crash occurred on the 15th query, so I thought the problem
might be a limitation on the number of open queries allowed. In
subsequent runs, it occurred at different points in the list, but just
to make sure I added this code before the query:
If ActiveSheet.QueryTables.Count > 0 Then
ActiveSheet.QueryTables(1).Delete
That did keep the query table small, but the problem persisted.I'm
stuck with breaking my list into small chunks and processing each chunk
separately. Clumsy, but it works.
Thinking that I might be running out of memory, I printed out
Application.MemoryFree,
Application.MemoryTotal
Application.MemoryUsed
before each query, and found that the numbers changed only slightly, so
that can't be it.
Any ideas would be welcome and appreciated.