Extremely SLOW Code

mikebecker

Board Regular
Joined
Mar 28, 2004
Messages
227
Why on earth does this code run so slow. Even on a blank workbook.

Sub Selldown_Headers()
Range("C2") = "0 to 10%"
Range("C3") = "11 to 20%"
Range("C4") = "21 to 30%"
Range("C5") = "31 to 40%"
Range("C6") = "41 to 50%"
Range("C7") = "Target 51 to 65%"
Range("C8") = "66 to 70%"
Range("C9") = "71 to 80%"
Range("C10") = "81 to 90%"
Range("C11") = "91 to 100%"
End Sub
Sub Selldown_Formulas()
 

Nimrod

MrExcel MVP
Joined
Apr 29, 2002
Messages
6,259
This code takes virtually no time to run on my system. Do you have alot of formula's that are being re-calculated in the workbook ? Turn you calculations to manual and see if that makes a difference.

This option is found under ..."Tools" ... "Options"... on the "Calculation Tab"
 

mikebecker

Board Regular
Joined
Mar 28, 2004
Messages
227
No Calculations.

I'll run this on a blank sheet and get the same.

I have even turned off most of my add-ins.
 

Nimrod

MrExcel MVP
Joined
Apr 29, 2002
Messages
6,259
Are any other macro's being triggered or run when these headings are be applied ?
 

PA HS Teacher

Well-known Member
Joined
Jul 17, 2004
Messages
2,839
Is there a work sheet change event? Have you tried disabling Macros?
 

PA HS Teacher

Well-known Member
Joined
Jul 17, 2004
Messages
2,839
Hello Nimrod, you are not confused, I am. In fact I think I may be running slower then the code in question.
[edit]

How about adding
Application.enableevents = false

Code


Applicaiton.enableevents = true
 

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,197
mikebecker said:
Why on earth does this code run so slow. Even on a blank workbook.
Just for the heck of it, reboot your computer, then create a new, fresh workbook, then name and save the workbook onto your hard drive (not a disk drive). Install this macro in it, and run it. Any better?


Sub Selldown_Headers()
With Application
Range("C2:C11").Value = _
.Transpose(Array( _
"0 to 10%", _
"11 to 20%", _
"21 to 30%", _
"31 to 40%", _
"41 to 50%", _
"Target 51 to 65%", _
"66 to 70%", _
"71 to 80%", _
"81 to 90%", _
"91 to 100%"))
End With
End Sub
 

mikebecker

Board Regular
Joined
Mar 28, 2004
Messages
227
no code running, no macros and no events.

But, Tom, your transposing the array works great and FAST!

Thanks, -Mike
 

Forum statistics

Threads
1,078,117
Messages
5,338,314
Members
399,226
Latest member
arictarhvasiliev

Some videos you may like

This Week's Hot Topics

Top