Same piece of code (with 20 Modules) produces different results

VBAProIWish

Well-known Member
Joined
Jul 6, 2009
Messages
1,027
Office Version
  1. 365
Platform
  1. Windows
Hello all,

I have a large program that spans 20 modules. If I run all 20 modules using a call command without a breakpoint, the code results in providing incorrect data. but if I put in just 1 breakpoint at around module 18 and then resume the code to finish through module 20, the code produces the correct result.

Anyone have any idea how or why this happens and how I can prevent it?

I don't want to have to create a breakpoint just so the code produces the correct result.

Thanks
 
Yes, that's exactly right. I am refreshing Pivot tables but now that you are saying that is not the cause of the problem, I don't know what is the cause. All I know is that if I stop (break) the code on one of the modules and then resume, it works fine. If I don't break the code it doesn't.

Any more thoughts as to what else the problem could be?

Thanks
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Not really as I would be guessing blindly unless I see the code. (this is a bit like turning up to a garage without your car and asking them to diagnose it based on a description that it doesn't work properly... ;))
 
Upvote 0
Is there some "pause" code that I can simply (and automatically) "pause" the code for like 2 seconds and then automatically resume the code?
 
Upvote 0
You can use DoEvents in a loop , though I always think that should be a last resort. After all, what if 2 seconds is sometimes not quite enough...?
 
Upvote 1
I found and used this code here on every other module and it worked!

VBA Code:
Application.Wait (Now + TimeValue("00:00:02"))

Thanks though for sticking with me on this!
 
Upvote 0
Solution

Forum statistics

Threads
1,215,069
Messages
6,122,952
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top