Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Writing cells using Range() slows down with successive writes

Hello,

I am creating a data logging system for an industrial application. I
need to write to 1000-10000 cells/second. My higher-level program
opens excel files, adds sheets, writes data, etc. The problem is when
I write array data using the Range() property, the writes slow down
drastically as the number of writes increases. Writing data using the
Cells() property does not cause this problem, but is far too slow to
get the job done.

Initially I thought this had something to do with the UNDO capability
in excel, but I disabled this in the registry. Furthermore, the UNDO
buffer is cleared when a save occurs. If I save, the problem still
exists. I also thought this problem could be somehow related to the
excel file growing, but I created a simple example that just rewrites
new data to only the first line, and the problem still exists. I have
also tried this with the excel window visible and hidden to see if it
was a screen-draw issue, but the problem still exists.

Here is some VBA code that shows the problem clearly (this problem
exists using VB 6.0 and external activex commands aswell). Each time
you run the subroutine, the write time increases when using the
Range() property. What could be causing this problem???

Thanks for any help!

Private Sub CommandButton1_Click()
Dim i As Long
Dim aryChars(256) As String
lngTimer = Timer

For i = 1 To 100
'create new/unique data for each cell
For j = 0 To 255
aryChars(j) = "A" & CStr(j) & CStr(i) & CStr(Timer)
Next

'if I use Range() alone, then problem
Range("A1:IV1").Value2 = aryChars()

'if I use Cells() alone, then NO problem
'Cells(1, 1).Value2 = aryChars(0)
Next

MsgBox "dt = " & CStr(Timer - lngTimer) & " seconds"
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 533
Default Writing cells using Range() slows down with successive writes

Charles Williams has a lot of information on Excel performance on his site.
I'm not sure if he addresses your issue directly but it might be worth
poking around there.

http://www.decisionmodels.com/index.htm

--
Jim
wrote in message
...
| Hello,
|
| I am creating a data logging system for an industrial application. I
| need to write to 1000-10000 cells/second. My higher-level program
| opens excel files, adds sheets, writes data, etc. The problem is when
| I write array data using the Range() property, the writes slow down
| drastically as the number of writes increases. Writing data using the
| Cells() property does not cause this problem, but is far too slow to
| get the job done.
|
| Initially I thought this had something to do with the UNDO capability
| in excel, but I disabled this in the registry. Furthermore, the UNDO
| buffer is cleared when a save occurs. If I save, the problem still
| exists. I also thought this problem could be somehow related to the
| excel file growing, but I created a simple example that just rewrites
| new data to only the first line, and the problem still exists. I have
| also tried this with the excel window visible and hidden to see if it
| was a screen-draw issue, but the problem still exists.
|
| Here is some VBA code that shows the problem clearly (this problem
| exists using VB 6.0 and external activex commands aswell). Each time
| you run the subroutine, the write time increases when using the
| Range() property. What could be causing this problem???
|
| Thanks for any help!
|
| Private Sub CommandButton1_Click()
| Dim i As Long
| Dim aryChars(256) As String
| lngTimer = Timer
|
| For i = 1 To 100
| 'create new/unique data for each cell
| For j = 0 To 255
| aryChars(j) = "A" & CStr(j) & CStr(i) & CStr(Timer)
| Next
|
| 'if I use Range() alone, then problem
| Range("A1:IV1").Value2 = aryChars()
|
| 'if I use Cells() alone, then NO problem
| 'Cells(1, 1).Value2 = aryChars(0)
| Next
|
| MsgBox "dt = " & CStr(Timer - lngTimer) & " seconds"
| End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not able to drag formula to successive cells manu213 Excel Discussion (Misc queries) 2 August 4th 09 07:07 AM
Writing array data to range object always writes 0's on worksheet eholz1 Excel Programming 5 September 22nd 07 03:54 AM
Pasting in successive cells Bob Excel Discussion (Misc queries) 6 January 3rd 07 03:10 AM
Writing to a range of cells BlockNinja Excel Programming 5 January 10th 06 08:15 AM
Speeding up writes to cells? Bruce E. Stemplewski Excel Programming 7 January 30th 05 11:59 PM


All times are GMT +1. The time now is 08:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"