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,082,116
Messages
5,363,251
Members
400,722
Latest member
DrewPop24

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top