![]() |
Suppressing Msgbox during Testing
Can't you just put a ' infront of the code you don't want
to be executed, thus making it a comment while you don't want it to run. -----Original Message----- Hi Please can someone provide a code snipprt or an idea to solve this neatly I have a utility that does some predetermined formatting on generic worksheets. In normal use it is used on ONE sheet at a time by the user. S/he may then use it later on another sheet. I want to test modifications against a set of sheets in a workbook consecutively in one go, which is fine but the routine itself has a MSGBOX command in it if it finds a particalar condition. I need to suppress this in the multi-sheet test. Otherwise it will be stopping unnecessarily as I would test that Msgbox condition independently. Can someone provide a suggestion,pl? Pl post back if above is not clear enough to enable a response. Thanks Tim . |
Suppressing Msgbox during Testing
Hi
thanks for those ideas...the reservations about these methods are they stop me being able to see what will happen if I am a user - I think it is risky to assume things will always work as you expect* that is why I want to turn the msgbox off just for the multi-sheet test. Commenting out the code is risky as I may not remember to uncomment it. Thanks Tim * I am often wrong-footed esp. as the complexity of interaction of differnet parameters increases "libby" wrote in message ... Can't you just put a ' infront of the code you don't want to be executed, thus making it a comment while you don't want it to run. -----Original Message----- Hi Please can someone provide a code snipprt or an idea to solve this neatly I have a utility that does some predetermined formatting on generic worksheets. In normal use it is used on ONE sheet at a time by the user. S/he may then use it later on another sheet. I want to test modifications against a set of sheets in a workbook consecutively in one go, which is fine but the routine itself has a MSGBOX command in it if it finds a particalar condition. I need to suppress this in the multi-sheet test. Otherwise it will be stopping unnecessarily as I would test that Msgbox condition independently. Can someone provide a suggestion,pl? Pl post back if above is not clear enough to enable a response. Thanks Tim . |
Suppressing Msgbox during Testing
Tim,
If you use the method to manually set a TestMode variable to true you can easily switch between the two modes. When working on "live" workbooks I usually use it in the following way: Sub TestMe() ' code that I know works End Sub If I'm trying to modify or enhance the code I do this with that same module: Sub TestMe() If TestMode = False Then ' code that I know works Else ' modified code that I'm testing End If End Sub Whenever I'm working on the workbook, I can set TestMode to True and do whatever I want with it. Since I have to manually set it to test, I never have to worry about the user running into my untested code and I can test it as a regular user myself. When I'm happy that everything works well, I just delete the if statements and my old code. I do the same for UserForms too. Place a button on the form to test some code, but set the button invisible IF TestMode = False. With the above method, whenever I have to release the workbook for someone else to use it, I don't have to worry about what I may heve left in there or was in the middle of when I save and close it. John Tim Childs wrote: Hi thanks for those ideas...the reservations about these methods are they stop me being able to see what will happen if I am a user - I think it is risky to assume things will always work as you expect* that is why I want to turn the msgbox off just for the multi-sheet test. Commenting out the code is risky as I may not remember to uncomment it. Thanks Tim * I am often wrong-footed esp. as the complexity of interaction of differnet parameters increases "libby" wrote in message ... Can't you just put a ' infront of the code you don't want to be executed, thus making it a comment while you don't want it to run. -----Original Message----- Hi Please can someone provide a code snipprt or an idea to solve this neatly I have a utility that does some predetermined formatting on generic worksheets. In normal use it is used on ONE sheet at a time by the user. S/he may then use it later on another sheet. I want to test modifications against a set of sheets in a workbook consecutively in one go, which is fine but the routine itself has a MSGBOX command in it if it finds a particalar condition. I need to suppress this in the multi-sheet test. Otherwise it will be stopping unnecessarily as I would test that Msgbox condition independently. Can someone provide a suggestion,pl? Pl post back if above is not clear enough to enable a response. Thanks Tim . |
Suppressing Msgbox during Testing
John
Many thanks for coming back with this further ost and explanation - I will try it out in my context Best wishes Tim |
All times are GMT +1. The time now is 07:28 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com