#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Array speed

I use the following code to write the data from a (8615 * 24) array to
worksheet
It is very fast before.
But I don't know why it is slow now.
Today, I spend 2.5 hours for this.
I want to know why and how to speed up. Many thanks.

Dim i As Long, j As Byte
For i = LBound(RMaster) To UBound(RMaster)
For j = 0 To 23
Cells(i + 2, j + 1 = RMaster(i, j)
Next
Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Array speed

I put the code below in a new workbook and it took under 10 seconds. Try
doing hte same. I think it is the workbook and not the macro. You may have
a lot of data or fromating in the workbook which would slow down the macro.
But it also may be your PC. I would try putting the workbook on another PC
to see what happens.

Sometimes deleting rows that are not used in teh worksheet may help. If you
worksheet goes to column Z then highlight all the columns to the right of you
data and delete the columns not used. Repeat for the rows. Try for all
worksheets.


Sub test()

Dim RMaster(8615, 24)
Dim i As Long, j As Byte
For i = LBound(RMaster) To UBound(RMaster)
For j = 0 To 23
Cells(i + 2, j + 1) = RMaster(i, j)
Next
Next


End Sub


"leungkong" wrote:

I use the following code to write the data from a (8615 * 24) array to
worksheet
It is very fast before.
But I don't know why it is slow now.
Today, I spend 2.5 hours for this.
I want to know why and how to speed up. Many thanks.

Dim i As Long, j As Byte
For i = LBound(RMaster) To UBound(RMaster)
For j = 0 To 23
Cells(i + 2, j + 1 = RMaster(i, j)
Next
Next

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default Array speed

I want to know why and how to speed up.
Dim i As Long, j As Byte



Hi. Just another approach...

Sub Demo()
Dim RMaster(8615, 24)
Dim d
'// Load RMaster w/ data...etc

d = Dimensions(RMaster)

[B1].Resize(d(0), d(1)) = RMaster
End Sub


Private Function Dimensions(m) As Variant
Dimensions = Array( _
UBound(m, 1) - LBound(m, 1) + 1, _
UBound(m, 2) - LBound(m, 2) + 1)
End Function


Dim i As Long, j As Byte


I believe the consensus here in the newsgroup is that "Byte" is not
often used for a looping type. There just doesn't seem to be any speed
improvement.

Note that the number of columns is 25 (ie 0 to 24)
Perhaps you could use something like this:

Dim RMaster(1 To 8615, 1 To 24)

= = = = = = =
HTH :)
Dana DeLouis



leungkong wrote:
I use the following code to write the data from a (8615 * 24) array to
worksheet
It is very fast before.
But I don't know why it is slow now.
Today, I spend 2.5 hours for this.
I want to know why and how to speed up. Many thanks.

Dim i As Long, j As Byte
For i = LBound(RMaster) To UBound(RMaster)
For j = 0 To 23
Cells(i + 2, j + 1 = RMaster(i, j)
Next
Next

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
Speed of array formula Cresta Excel Worksheet Functions 1 August 18th 09 09:06 AM
Speed of fixed array versus dynamic array Sing Excel Programming 8 November 18th 07 10:19 AM
Using an Array instead of a Vlookup to improve speed Frank & Pam Hayes[_2_] Excel Programming 4 August 10th 05 08:01 PM
Speed up performance for very big array Cool Sport Excel Programming 10 December 15th 04 09:53 AM
VBA - speed up macro, working with array? freseh[_2_] Excel Programming 1 September 15th 04 10:23 AM


All times are GMT +1. The time now is 07:56 PM.

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"