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:
' ' excel data stuff --- shows that on this machine (750Mhz PIII) you can ' stuff about 180 cells per second, which is STUNNINGLY slow based on ' the processor speed; SO ... it must be that there is a connection that ' gets established for every cell stuff & if that connection could be ' kept open, it might take WAY less time to stuff all the data ' ' the doevents does not make any difference in the amount of time the ' whole thing takes, but without the doevents, the timer counts never ' happen ' Option Explicit Public xlApp As Excel.Application Public xlBook As Excel.Workbook Public xlSheet As Excel.Worksheet Public xlRows As Integer Public seconds As Integer ' ' ' Private Sub cmdDoIt_Click() Dim ix As Integer, iy As Integer Dim row As Integer, col As Integer Set xlApp = New Excel.Application Set xlBook = xlApp.Workbooks.Open(App.Path & "\Book1.xls", , True) Set xlSheet = xlBook.Worksheets("Data") seconds = 0 For ix = 0 To 600 row = 2 + ix For iy = 0 To 36 col = 2 + iy ' xlSheet.Cells(row, col).Value = CStr(iy + ix * 10) ' as strings xlSheet.Cells(row, col).Value = iy + ix * 10 ' as integers Next iy Next ix xlApp.Workbooks.Close xlApp.Quit Set xlApp = Nothing End Sub




Reply With Quote