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()
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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"
 
Upvote 0
No Calculations.

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

I have even turned off most of my add-ins.
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
no code running, no macros and no events.

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

Thanks, -Mike
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,986
Members
448,538
Latest member
alex78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top