ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Really slow code (just this one section) (https://www.excelbanter.com/excel-programming/359495-really-slow-code-just-one-section.html)

KR

Really slow code (just this one section)
 
I pull data into an array and perform several calculations; now I just need
to dump it back into my spreadsheet. For some reason, the code below is
taking 3-4 seconds per loop (of v); each loop only has to paste 8 values in
8 cells! The rest of the code runs very, very fast, it is only this section
of code that is so slow. Any suggestions on why it might be slow, and how to
speed it up?
Thanks,
Keith
XL2003 on Win2000

<snip
For v = 1 To LastOut 'about 3000+ rows
vt = Trim(Str(v)) 'do this conversion once, instead of with each
range assignment
Application.StatusBar = "Pasting row " & vt & " of " & Str(LastOut) 'this is
so I know how fast it is[n't] going
For PasteCol = 17 To 20
UsePasteCol = Chr(PasteCol + 64)
Sheet3.Range(UsePasteCol & vt).Value = OutArr(PasteCol, v)
Next
For PasteCol = 23 To 26
UsePasteCol = Chr(PasteCol + 64)
Sheet3.Range(UsePasteCol & vt).Value = OutArr(PasteCol, v)
Next
Next
<snip

--
The enclosed questions or comments are entirely mine and don't represent the
thoughts, views, or policy of my employer. Any errors or omissions are my
own.



Jim Thomlinson

Really slow code (just this one section)
 
Is your calculation enabled while this code is running. if it is having to
re-calc with each loop that could account for the significant time...
--
HTH...

Jim Thomlinson


"KR" wrote:

I pull data into an array and perform several calculations; now I just need
to dump it back into my spreadsheet. For some reason, the code below is
taking 3-4 seconds per loop (of v); each loop only has to paste 8 values in
8 cells! The rest of the code runs very, very fast, it is only this section
of code that is so slow. Any suggestions on why it might be slow, and how to
speed it up?
Thanks,
Keith
XL2003 on Win2000

<snip
For v = 1 To LastOut 'about 3000+ rows
vt = Trim(Str(v)) 'do this conversion once, instead of with each
range assignment
Application.StatusBar = "Pasting row " & vt & " of " & Str(LastOut) 'this is
so I know how fast it is[n't] going
For PasteCol = 17 To 20
UsePasteCol = Chr(PasteCol + 64)
Sheet3.Range(UsePasteCol & vt).Value = OutArr(PasteCol, v)
Next
For PasteCol = 23 To 26
UsePasteCol = Chr(PasteCol + 64)
Sheet3.Range(UsePasteCol & vt).Value = OutArr(PasteCol, v)
Next
Next
<snip

--
The enclosed questions or comments are entirely mine and don't represent the
thoughts, views, or policy of my employer. Any errors or omissions are my
own.




KR

Really slow code (just this one section)
 
Ah, good point- I hadn't added any formulas of note, but now that I've
turned off calculation, it is running at full speed- one of the other other
users must have added some.
Thanks!!
Keith

"Jim Thomlinson" wrote in message
...
Is your calculation enabled while this code is running. if it is having to
re-calc with each loop that could account for the significant time...
--
HTH...

Jim Thomlinson


"KR" wrote:

I pull data into an array and perform several calculations; now I just

need
to dump it back into my spreadsheet. For some reason, the code below is
taking 3-4 seconds per loop (of v); each loop only has to paste 8 values

in
8 cells! The rest of the code runs very, very fast, it is only this

section
of code that is so slow. Any suggestions on why it might be slow, and

how to
speed it up?
Thanks,
Keith
XL2003 on Win2000

<snip
For v = 1 To LastOut 'about 3000+ rows
vt = Trim(Str(v)) 'do this conversion once, instead of with

each
range assignment
Application.StatusBar = "Pasting row " & vt & " of " & Str(LastOut)

'this is
so I know how fast it is[n't] going
For PasteCol = 17 To 20
UsePasteCol = Chr(PasteCol + 64)
Sheet3.Range(UsePasteCol & vt).Value = OutArr(PasteCol, v)
Next
For PasteCol = 23 To 26
UsePasteCol = Chr(PasteCol + 64)
Sheet3.Range(UsePasteCol & vt).Value = OutArr(PasteCol, v)
Next
Next
<snip

--
The enclosed questions or comments are entirely mine and don't represent

the
thoughts, views, or policy of my employer. Any errors or omissions are

my
own.







All times are GMT +1. The time now is 06:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com