Strange Debugging

hotabae

Board Regular
Joined
Apr 18, 2018
Messages
167
Hello!

I've had this issue crop up a few times now in the same project, and I can't make heads or tails of it.

The most recent time:

I have 5 comboBox shapes on a worksheet, and when 1 of the comboBoxes changes it resets the other 4.

Code looks something like this:

Code:
            ActiveSheet.Shapes("cBox1").OLEFormat.Object.value = 1
            ActiveSheet.Shapes("cBox3").OLEFormat.Object.value = 1
            ActiveSheet.Shapes("cBox4").OLEFormat.Object.value = 1
            ActiveSheet.Shapes("cBox5").OLEFormat.Object.value = 1

For some reason, If you do them in a specific order, Excel crashes pretty much instantaneously. (crashes if you click cbox 2,3 then 5; but it doesn't crash in any other order)

To try and figure it out, I tried Stepping through the code in break mode. I was surprised to find that my code ran just fine while in break mode.

Next, I ran the same code with a message box near the end of the code. What happened there was a bit strange. If I clicked through the message box right away, it crashed, but if I waited a few seconds before clicking "OK" then it ran without crashes...

Next up, I commented out different lines of code and found no errors. But now, when I uncommented everything and removed the messagebox line (basically reverting to the 'pre-debug' stage), everything is working, and it is not crashing anymore.

I seem to have fixed it, but I don't know what changed.... Any thoughts?
 
Last edited:

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Sounds like it might be that the code is being moved on before it has finished processing the new info.
Try doing a Google search on Application.Wait and DoEvents Excel VBA for ideas.

Btw, I don't see a Box 2 in the code.
 
Last edited:
Upvote 0
Btw, I don't see a Box 2 in the code.

Yeah, it was sorta an example of what happens when box 2 is activated (1,3,4,5 reset).

I'll take a look at that stuff, seems like a good way to handle this issue if it pops up again.

Just seemed strange that I fixed a problem without actually doing anything...

Thanks!
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

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