Different results when running macro vs stepping into macro

K

Ken Steinhoff

My boss built a macro which returns different results when run than
when he steps through it.

Before I get specific about what the macro does (since I don't have it
in front of me), I thought I'd ask the general question about what
might cause that to happen.

If the macro works when executed manually step-by-step, I would think
it should work the same way when launched.

Ideas? Comments?
 
M

Marcus =?iso-8859-15?Q?Sch=F6neborn?=

»Ken Steinhoff« said:
My boss built a macro which returns different results when run than
when he steps through it.

Before I get specific about what the macro does (since I don't have it
in front of me), I thought I'd ask the general question about what
might cause that to happen.

If the macro works when executed manually step-by-step, I would think
it should work the same way when launched.

It may access the current time multiple times:

t1 = time() - value1 ' age of value1
t2 = time() - value2 ' age of value2
dt = t2 - t1 ' age difference

When single stepping, dt can be LARGER than value1 - value2, although
it's equal when running at once.
 
G

Gary Keramidas

just a thought. are you changing sheets to check results as you step through the
macro? i would make sure the ranges are fully qualified. maybe someone else will
have a better idea.
 
J

JE McGimpsey

Just a guess, but if the macro depends on a Selection(s), it may be that
when your boss starts the step-through the Selection works, but not when
run from the menu.
 
T

Tim Williams

If there are any "external" operations which run asynchronously with the VBA
then you may get different results depending on how long those operations
take. For example, automating a web page from VBA without waiting for (eg)
pages to complete loading before trying to interact with them will show this
type of difference.

Tim.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top