troubleshooting Question

Time Taken to Run Macro does not match reality

Avatar of JimboP34
JimboP34 asked on
Microsoft Excel
17 Comments2 Solutions241 ViewsLast Modified:
Dear all

I have two issues with the attached code:

1) Only the first message box saying "1/10 of the way there" comes up. 1/9 and 1/8 etc do not.

2)The time stated in the msgbox is a fraction of a second - whearas in reallity takes about 20 seconds or so.

Any thoughts?


Sub Macro1()
Dim TimeA As Variant
Dim n As Long
Dim z As Long

z = 10

TimeA = Now()

MsgBox 100000000

Do Until n = 100000000

n = n + 1

If n = ((100000000) / z) Then
  MsgBox "1/" & z & " of the way there!"
  z = z - 1
  MsgBox "z is " & z
End If


TimeA = Now() - TimeA

MsgBox TimeA
MsgBox n

End Sub
Join our community to see this answer!
Unlock 2 Answers and 17 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 17 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros