View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default EXCEPTIONALLY SLOW LOOP ....help!!!

It takes about the same time as looping through and writing to 700 cells -
which is essentially what you are doing. If you have formulas that reference
these cells, try turning calculation to manual before running it. (or turn
it off in your code at the beginning and back on at the end). Also, make
sure you don't have visible pagebreaks - this can also slow down macros.

Anyway, it was pretty much instantaneous for me - so I assume it has to be
some factor to do with your spreadsheet.

--
Regards,
Tom Ogilvy


"WhytheQ" wrote:

I can't see any reason why the following loop should take so long to
execute.....

For i = 1 To 35
For j = 1 To 20
Worksheets("Income").Cells(20* (i - 1) + j + 1, 200) =
income(i, j)
Next j
Next i

.....the 2 dimensional array 'income' has been filled, before the above
executes, with the correct numner of elements i.e income(1 to 35,1 to
20).
It's like watching paint dry when the above executes!

Any help greatly appreciated.

Jason