program won't end at the end of the last sub

windwardkey

New Member
Joined
Dec 9, 2017
Messages
13
I have an foreign language learning program. Simplified a little, on a user form I designate a verb, e.g., “buy” and click “start.” A sub randomly selects a person, e.g., “I”, “you,” or “they,” puts the English in cell (2, 2) and the Italian in cell (3, 2), and then calls a sub named “tense().” That sub randomly selects from among “present,” “imperfect,” and “future,” and puts the English verb in cell (2, 3) and the Italian in cell (3, 3) It also puts information in cells (2, 1) and (3, 1), like “Today” if present tense has been selected and “Tomorrow” if future tense. That sub ends by calling “closing.” That adds a direct object in cells (2, 4) and (3, 4) and posts the complete English sentence on the user from, e.g., “Today I am buying a car,” or “Tomorrow they will buy a car.” I then type the Italian sentence in a space on the form, and then click “check answer,” and another form shows my sentence next to the correct Italian sentence.

Here’s the problem. When the sub “closing” reaches “End Sub” the program acts as if there was either a line with Call Tense or one calling one of the specific tenses. Typically it then decides to stop after 2 to 6 iterations. The result is a mishmash—“Yesterday they will buy a car,” or Tomorrow I used to buy a car.”

How can I make the program stop at the end of the last sub? I’ve tried to solve the problem by a “Stop,” but that closes the userform.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I don't believe it is possible to tell you exactly what to do to fix your problem without seeing the code. But you can look for the probolem by using the F8 function key to step through your code line by line so you can see exactly what it is doing when the closing sub is called and executes. Just open the vb editor click inside the sub that calls the closing sub and then press F8. The title line of the code should display a yellow highlight. As the highlight moves to the next line of code the previous line will have executed. You can hover the mouse pointer over your variables to see what values they hold with the tool tips pop up display. When the macro call executes for 'closing', it will automatically jump the highlight to that macro and you just continue stepping through. Since it is called from another macro, when the 'closing' macro finishes executing, the highlight will jump back to the calling macro and I suspect that at that point you will see where the continuation of code execution occurs.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,208
Members
448,554
Latest member
Gleisner2

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