Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Can't get the macro to quit
This is perplexing.........I have three macro's (I removed all the 'work'
portion of the code to shorten it) but basically, If I follow the path of auto_open, VbNo then Beginning_Week, vbYes, I get to the macro Daily but when I get to the bottom of the sub Daily, it doesn't end. For some reason it jumps to other End Sub's code line and then starts executing lines of code again. I have tried many different configurations without success. Any ideas? I wasn't aware that "End Sub" would not end the code execution???!! ! Help and many thanks. Carrie Option Explicit Sub auto_open() Dim ans As Long ' If user answers yes then follow code below if user answers no then envoke macro asking if it is the beginning of the week ans = MsgBox("Is this the end of the Week?", vbYesNo) If ans = vbNo Then Call Begin_Week ' Saves Ending Inventory Balance then envokes macro for Daily Input Call Daily End Sub Sub Begin_Week() Dim ans As Long ' If user answers yes then follow code below if user answers no then envoke macro for Daily Input ans = MsgBox("Is this the beginning of the Week?", vbYesNo) If ans = vbNo Then Call Daily ' Clear contents of all Data Entry Sections ' Copy Ending Inventory from Last week to new worksheet ' Save Changes ' Envoke Macro for Daily Input Call Daily End Sub Sub Daily() Dim ans As Long ' If user answers yes then follow code below if user answers no then envoke macro for Daily Input ans = MsgBox(Prompt:="Ready for Daily Input?", Buttons:=vbYesNo) If ans = vbNo Then Call auto_open End If €˜Begin Input End Sub -- Message posted via http://www.officekb.com |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Can't get the macro to quit
hi
looks like you are caught in a endless loop. sub auto_open calls sub daily which calls sub auto_open which calls sub daily...... and on and on and on....... why are we calling sub auto_open at the end of daily???????? regards FSt1 "Carrie_Loos via OfficeKB.com" wrote: This is perplexing.........I have three macro's (I removed all the 'work' portion of the code to shorten it) but basically, If I follow the path of auto_open, VbNo then Beginning_Week, vbYes, I get to the macro Daily but when I get to the bottom of the sub Daily, it doesn't end. For some reason it jumps to other End Sub's code line and then starts executing lines of code again. I have tried many different configurations without success. Any ideas? I wasn't aware that "End Sub" would not end the code execution???!! ! Help and many thanks. Carrie Option Explicit Sub auto_open() Dim ans As Long ' If user answers yes then follow code below if user answers no then envoke macro asking if it is the beginning of the week ans = MsgBox("Is this the end of the Week?", vbYesNo) If ans = vbNo Then Call Begin_Week ' Saves Ending Inventory Balance then envokes macro for Daily Input Call Daily End Sub Sub Begin_Week() Dim ans As Long ' If user answers yes then follow code below if user answers no then envoke macro for Daily Input ans = MsgBox("Is this the beginning of the Week?", vbYesNo) If ans = vbNo Then Call Daily ' Clear contents of all Data Entry Sections ' Copy Ending Inventory from Last week to new worksheet ' Save Changes ' Envoke Macro for Daily Input Call Daily End Sub Sub Daily() Dim ans As Long ' If user answers yes then follow code below if user answers no then envoke macro for Daily Input ans = MsgBox(Prompt:="Ready for Daily Input?", Buttons:=vbYesNo) If ans = vbNo Then Call auto_open End If €˜Begin Input End Sub -- Message posted via http://www.officekb.com |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Can't get the macro to quit
Hi,
When you run Auto_Open you and the user responds NO ultimately The code will return to that routine at the line after If ans = vbNo Then Call Begin_Week The next line is Call Daily So if the user presses NO then both macros are called and I doubt that's what you intend. If you put both calls in an If loop then when execution returns to auto_open it will be after the end if so that won't happen Sub auto_open() Dim ans As Long ans = MsgBox("Is this the end of the Week?", vbYesNo) If ans = vbNo Then Begin_Week Else Call Daily End If End Sub Mike "Carrie_Loos via OfficeKB.com" wrote: This is perplexing.........I have three macro's (I removed all the 'work' portion of the code to shorten it) but basically, If I follow the path of auto_open, VbNo then Beginning_Week, vbYes, I get to the macro Daily but when I get to the bottom of the sub Daily, it doesn't end. For some reason it jumps to other End Sub's code line and then starts executing lines of code again. I have tried many different configurations without success. Any ideas? I wasn't aware that "End Sub" would not end the code execution???!! ! Help and many thanks. Carrie Option Explicit Sub auto_open() Dim ans As Long ' If user answers yes then follow code below if user answers no then envoke macro asking if it is the beginning of the week ans = MsgBox("Is this the end of the Week?", vbYesNo) If ans = vbNo Then Call Begin_Week ' Saves Ending Inventory Balance then envokes macro for Daily Input Call Daily End Sub Sub Begin_Week() Dim ans As Long ' If user answers yes then follow code below if user answers no then envoke macro for Daily Input ans = MsgBox("Is this the beginning of the Week?", vbYesNo) If ans = vbNo Then Call Daily ' Clear contents of all Data Entry Sections ' Copy Ending Inventory from Last week to new worksheet ' Save Changes ' Envoke Macro for Daily Input Call Daily End Sub Sub Daily() Dim ans As Long ' If user answers yes then follow code below if user answers no then envoke macro for Daily Input ans = MsgBox(Prompt:="Ready for Daily Input?", Buttons:=vbYesNo) If ans = vbNo Then Call auto_open End If €˜Begin Input End Sub -- Message posted via http://www.officekb.com |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Can't get the macro to quit
That's what I figured but shouldn't it only call auto_open if the user
answers no on the button? Otherwise it should read through the code for vbYes, as it does and then End Sub. Why doesn't End Sub do just that when it is reading the line End Sub? I have stepped through it several times......??? FYI - I recall auto_open in case the user made a mistake and needs to start again. P.S. I have even removed the auto_open from the code and re-tested. It still won't end. Thx for any assistance with this FSt1 wrote: hi looks like you are caught in a endless loop. sub auto_open calls sub daily which calls sub auto_open which calls sub daily...... and on and on and on....... why are we calling sub auto_open at the end of daily???????? regards FSt1 This is perplexing.........I have three macro's (I removed all the 'work' portion of the code to shorten it) but basically, If I follow the path of [quoted text clipped - 54 lines] €˜Begin Input End Sub -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...excel/200805/1 |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Can't get the macro to quit
hi
should have read closer. you are right but remember that daily was invoked by a call. when it finishes, code exccution returns to the calling sub to complete to it's end sub. so just because the code hit an end sub doen't mean that that is the end of the code run, just the end of that sub. mike has a good idea. check that out. regards FSt1 "Carrie_Loos via OfficeKB.com" wrote: That's what I figured but shouldn't it only call auto_open if the user answers no on the button? Otherwise it should read through the code for vbYes, as it does and then End Sub. Why doesn't End Sub do just that when it is reading the line End Sub? I have stepped through it several times......??? FYI - I recall auto_open in case the user made a mistake and needs to start again. P.S. I have even removed the auto_open from the code and re-tested. It still won't end. Thx for any assistance with this FSt1 wrote: hi looks like you are caught in a endless loop. sub auto_open calls sub daily which calls sub auto_open which calls sub daily...... and on and on and on....... why are we calling sub auto_open at the end of daily???????? regards FSt1 This is perplexing.........I have three macro's (I removed all the 'work' portion of the code to shorten it) but basically, If I follow the path of [quoted text clipped - 54 lines] €˜Begin Input End Sub -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...excel/200805/1 |
#6
Posted to microsoft.public.excel.misc
|
|||
|
|||
Can't get the macro to quit
Oh - I didn't think about that with a call. Interesting. Love to learn new
things. Thanks FSt1 wrote: hi should have read closer. you are right but remember that daily was invoked by a call. when it finishes, code exccution returns to the calling sub to complete to it's end sub. so just because the code hit an end sub doen't mean that that is the end of the code run, just the end of that sub. mike has a good idea. check that out. regards FSt1 That's what I figured but shouldn't it only call auto_open if the user answers no on the button? Otherwise it should read through the code for vbYes, [quoted text clipped - 24 lines] €˜Begin Input End Sub -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...excel/200805/1 |
#7
Posted to microsoft.public.excel.misc
|
|||
|
|||
Can't get the macro to quit
Thanks for your help Mike - I could not have moved forward without your info..
...still having a couple of issues but now that I know how it's reading I can fix it. Mike H wrote: Hi, When you run Auto_Open you and the user responds NO ultimately The code will return to that routine at the line after If ans = vbNo Then Call Begin_Week The next line is Call Daily So if the user presses NO then both macros are called and I doubt that's what you intend. If you put both calls in an If loop then when execution returns to auto_open it will be after the end if so that won't happen Sub auto_open() Dim ans As Long ans = MsgBox("Is this the end of the Week?", vbYesNo) If ans = vbNo Then Begin_Week Else Call Daily End If End Sub Mike This is perplexing.........I have three macro's (I removed all the 'work' portion of the code to shorten it) but basically, If I follow the path of [quoted text clipped - 54 lines] €˜Begin Input End Sub -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...excel/200805/1 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to quit application | Excel Discussion (Misc queries) | |||
quit ie from excel macro | Excel Discussion (Misc queries) | |||
Excel application.quit in macro problem | New Users to Excel | |||
Formulas quit--- | Excel Worksheet Functions | |||
Excel won't quit | Excel Discussion (Misc queries) |