|
-
Dec 14th, 2001, 08:54 AM
#1
Thread Starter
Registered User
writing an array into a range
My program runs really slow. And I was wondering if it is because I use like 500 statements like this
For i = 1 To 10000
X2.Worksheets(1).Cells(y, 7) = MagneticDrag4(x)
x = x + 1
y = y + 1
Next i
Is there a better way to write the entire array into a column?
Thanks,
JEFF
-
Dec 14th, 2001, 09:04 AM
#2
Retired VBF Adm1nistrator
Well one thing that will speed it up a little ;
VB Code:
For i = 1 To 10000
'put code here
Next
See there's no index reference after the word Next.
That should speed up the loop.
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Dec 14th, 2001, 09:19 AM
#3
Conquistador
what is ur code trying to achieve?
w00t 4000 posts !
-
Dec 14th, 2001, 09:21 AM
#4
Addicted Member
Just out of curiousity when/where/how do you fill your array?
-
Dec 14th, 2001, 09:22 AM
#5
Conquistador
Originally posted by Supester
Just out of curiousity when/where/how do you fill your array?
a cut and paste job?
http://www.vbforums.com/showthread.p...hreadid=127118

why did you do that?
-
Dec 14th, 2001, 09:23 AM
#6
Conquistador
actually, he doesn't even fill an array, so how is this relevant
it seems as though he is not using an array :rolleys:
-
Dec 14th, 2001, 09:25 AM
#7
Addicted Member
da_sil....whatever, you got your 3000/4000 mail-count...cut the crap....start reply-ing to answers instead of some corny remark.....look at the thread again, I already posted that it was a in the wrong thread
-
Dec 14th, 2001, 09:36 AM
#8
Thread Starter
Registered User
MagneticDrag4 is an array with about 10000 data points.
Like MagneticDrag4(1) = 4.5 etc. ......MagneticDrag4(10000) = 0
The problem is I am writing that array to an excel worksheets to graph it. so currently, I am writing the array, one data point at a time in a loop. And because I have 100 arrays, it takes like 15 minutes to run. I was wondering if there was a way to somehow just say, take the array and fill into the excel column.
Thanks,
JEFF
-
Dec 14th, 2001, 10:35 AM
#9
Addicted Member
Here's my idea, don't know whether it is faster, but you never know...
there is a function in word to get a table as a text and you can copy/paste tables...
you can try:
- send the array as a string to word
- let Word convert the text to a table
- copy and paste the table to excel
maybe this is faster?
Have fun trying...if you are going to try it
-
Dec 14th, 2001, 10:37 AM
#10
Conquistador
Originally posted by Supester
da_sil....whatever, you got your 3000/4000 mail-count...cut the crap....start reply-ing to answers instead of some corny remark.....look at the thread again, I already posted that it was a in the wrong thread
i do reply to threads, that's why i have a high post count
i am allowed to post some garbage ones ocassionally too
search thru enough of my posts and you'll find most of them help the person
-
Dec 14th, 2001, 11:52 AM
#11
Fanatic Member
Originally posted by jkw119
MagneticDrag4 is an array with about 10000 data points.
Like MagneticDrag4(1) = 4.5 etc. ......MagneticDrag4(10000) = 0
The problem is I am writing that array to an excel worksheets to graph it. so currently, I am writing the array, one data point at a time in a loop. And because I have 100 arrays, it takes like 15 minutes to run. I was wondering if there was a way to somehow just say, take the array and fill into the excel column.
Thanks,
JEFF
Can you put the data into a recordset instead of an array? If you can then you'll be able to lump it all into Excel in one go:
VB Code:
ActiveCell.CopyFromRecordset rstRecordsetName
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|