I'm using VB to stuff data into an existing excel spreadsheet, and I can hardly believe how SLOW it is. On a 750Mhz PIII, I get 180 cells per second. Does anyone have any idea why this is so slow?

My code is below if you're interested.

VB Code:
  1. '
  2. ' excel data stuff --- shows that on this machine (750Mhz PIII) you can
  3. ' stuff about 180 cells per second, which is STUNNINGLY slow based on
  4. ' the processor speed; SO ... it must be that there is a connection that
  5. ' gets established for every cell stuff & if that connection could be
  6. ' kept open, it might take WAY less time to stuff all the data
  7. '
  8. ' the doevents does not make any difference in the amount of time the
  9. ' whole thing takes, but without the doevents, the timer counts never
  10. ' happen
  11. '
  12. Option Explicit
  13. Public xlApp As Excel.Application
  14. Public xlBook As Excel.Workbook
  15. Public xlSheet As Excel.Worksheet
  16. Public xlRows As Integer
  17. Public seconds As Integer
  18. '
  19. '
  20. '
  21. Private Sub cmdDoIt_Click()
  22.     Dim ix As Integer, iy As Integer
  23.     Dim row As Integer, col As Integer
  24.    
  25.  
  26.     Set xlApp = New Excel.Application
  27.     Set xlBook = xlApp.Workbooks.Open(App.Path & "\Book1.xls", , True)
  28.     Set xlSheet = xlBook.Worksheets("Data")
  29.    
  30.     seconds = 0
  31.     For ix = 0 To 600
  32.         row = 2 + ix
  33.         For iy = 0 To 36
  34.             col = 2 + iy
  35. '            xlSheet.Cells(row, col).Value = CStr(iy + ix * 10) ' as strings
  36.             xlSheet.Cells(row, col).Value = iy + ix * 10    ' as integers
  37.         Next iy
  38.     Next ix
  39.  
  40.     xlApp.Workbooks.Close
  41.     xlApp.Quit
  42.     Set xlApp = Nothing
  43. End Sub