Exceptionally slow Excel 2007 Macros

DaBean

New Member
Hi all,

I am new to the forum and to troubleshooting computer issues, but this one is driving me insane. I have noticed that my desktop is very slow at running Excel 2007 macros, when I believe that it should not be. I decided to do a test, and run it on my machine and then on my friend's machine.

The test the following: I run a loop of 100,000 iterations of putting the i'th number on the i'th row, and time it. Here are my results (in the first column) and my friend's in the second:

1.___3.84___6.14
2.___3.80___6.14
3.___3.82___6.14
4.___4.57___6.14
5.___5.93___6.12
6.___7.77___7.15
7.___10.23__6.09
8.___10.90__6.14
9.___11.83__6.46
10.__12.58__6.17
11.__13.17
12.__13.90
13.__14.03
14.__14.73
15.__14.09
16.__14.09
17.__14.08
18.__14.12
19.__14.14
20.__14.05


Can anyone explain why mine starts out so quickly (the speed I expect, given the computer specs) and climbs to 14 seconds and hangs out there?

The real issue is that I'm writing code that should normally take on the order of 15-20 minutes to run through all the operations, but instead is taking 2-3 hours. Running several iterations of that is extremely slow and time-consuming.

Here is the code that I used. I don't think that it's relevant, as the exact same code generated the two sets of results on the two computers, but here it is anyway:

Private Sub CommandButton1_Click()
Dim time1, time2, time3
Dim i, n As Integer

For n = 1 To 20
time1 = Timer

For i = 1 To 100000
Cells(i, 1).Value = i
Next i

time2 = Timer

time3 = time2 - time1
Cells(1, n + 1).Value = time3
Cells(2, n + 1).Value = time3 / i
Next n

End Sub
 

My Computer

Back
Top