![]() |
message box sometimes not being called
I will be grateful for any ideas any one has on the following.
I have a long macro that when run sometimes calls the message box as below and sometimes does not. I have tried including it in the macro code and also tried calling it (ie having it separate) and the only way i can make it work every time is to in effect stop the macro by putting another message box before it such as 'msgbox "xyz" ' this has the effect of stopping the macro and it runs every time. As you will note it is a basic message box. Code as below Public hols As Boolean( i actually declare this at the top with other public declarations) Dim Msg, Style, Title, holiday Msg = "Was yesterday a holiday ?" Style = vbYesNo Title = "Holiday?" holiday = MsgBox(Msg, Style, Title) If holiday = vbYes Then hols = True If holiday = vbNo Then hols = False This then sets the hols variable to true or false. -- with kind regards Spike |
message box sometimes not being called
I don't see anything in the code you posted that would cause a problem.
Maybe the problem is in the surrounding code??? Spike wrote: I will be grateful for any ideas any one has on the following. I have a long macro that when run sometimes calls the message box as below and sometimes does not. I have tried including it in the macro code and also tried calling it (ie having it separate) and the only way i can make it work every time is to in effect stop the macro by putting another message box before it such as 'msgbox "xyz" ' this has the effect of stopping the macro and it runs every time. As you will note it is a basic message box. Code as below Public hols As Boolean( i actually declare this at the top with other public declarations) Dim Msg, Style, Title, holiday Msg = "Was yesterday a holiday ?" Style = vbYesNo Title = "Holiday?" holiday = MsgBox(Msg, Style, Title) If holiday = vbYes Then hols = True If holiday = vbNo Then hols = False This then sets the hols variable to true or false. -- with kind regards Spike -- Dave Peterson |
message box sometimes not being called
Yes you could be right. It is tied up with several if statements and select
case etc but it is at the start of a macro that is called by another after all the declarations etc it is as if it is running too fast!!! if you get the drift. As i say if i put a simple msbox in it stops the code running and then it seems to work everytime. Thanks, i will pursevere"!!! -- with kind regards Spike "Dave Peterson" wrote: I don't see anything in the code you posted that would cause a problem. Maybe the problem is in the surrounding code??? Spike wrote: I will be grateful for any ideas any one has on the following. I have a long macro that when run sometimes calls the message box as below and sometimes does not. I have tried including it in the macro code and also tried calling it (ie having it separate) and the only way i can make it work every time is to in effect stop the macro by putting another message box before it such as 'msgbox "xyz" ' this has the effect of stopping the macro and it runs every time. As you will note it is a basic message box. Code as below Public hols As Boolean( i actually declare this at the top with other public declarations) Dim Msg, Style, Title, holiday Msg = "Was yesterday a holiday ?" Style = vbYesNo Title = "Holiday?" holiday = MsgBox(Msg, Style, Title) If holiday = vbYes Then hols = True If holiday = vbNo Then hols = False This then sets the hols variable to true or false. -- with kind regards Spike -- Dave Peterson |
message box sometimes not being called
I think Dave was hinting that you should post the other code in the macro.
That way we can see if there is something else causing the problem. "Spike" wrote: Yes you could be right. It is tied up with several if statements and select case etc but it is at the start of a macro that is called by another after all the declarations etc it is as if it is running too fast!!! if you get the drift. As i say if i put a simple msbox in it stops the code running and then it seems to work everytime. Thanks, i will pursevere"!!! -- with kind regards Spike "Dave Peterson" wrote: I don't see anything in the code you posted that would cause a problem. Maybe the problem is in the surrounding code??? Spike wrote: I will be grateful for any ideas any one has on the following. I have a long macro that when run sometimes calls the message box as below and sometimes does not. I have tried including it in the macro code and also tried calling it (ie having it separate) and the only way i can make it work every time is to in effect stop the macro by putting another message box before it such as 'msgbox "xyz" ' this has the effect of stopping the macro and it runs every time. As you will note it is a basic message box. Code as below Public hols As Boolean( i actually declare this at the top with other public declarations) Dim Msg, Style, Title, holiday Msg = "Was yesterday a holiday ?" Style = vbYesNo Title = "Holiday?" holiday = MsgBox(Msg, Style, Title) If holiday = vbYes Then hols = True If holiday = vbNo Then hols = False This then sets the hols variable to true or false. -- with kind regards Spike -- Dave Peterson |
All times are GMT +1. The time now is 01:16 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com