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,081,524
Messages
5,359,269
Members
400,523
Latest member
ExcelNewbie98

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top