![]() |
VbYesNo MsgBox won't respond to "No"
Apologies to those of you who've already picked this up in the Excel forum.
Can anyone see the deliberate error with this code - no matter what button I click, it always processes the vbYes option. Response returns "7" when i click "No" and "6" when I click "Yes". All help gratefuly received! :-) Sub ConfirmIssuesDelete() Dim Prompt, Buttons, Title, Help, Ctxt, Response, MyString Prompt = "Do you REALLY want to delete this row?" ' Message. Buttons = vbYesNo + vbCritical + vbDefaultButton1 ' Buttons. Title = "Whoa!" ' Title. Help = "D:\DEMO.TXT" ' Define Help file. Ctxt = 1000 ' Define topic Response = MsgBox(Prompt, Buttons, Title, Help, Ctxt) MsgBox (Response) If Response = vbYes Then WhereWasI = (Selection.Address) Selection.EntireRow.Delete IssuesDataRangeFormat Range(WhereWasI).Select Else Exit Sub End If End Sub |
VbYesNo MsgBox won't respond to "No"
it works fine in Excel 2000 after I declared 'WhereWasI' and commented
'IssuesDataRangeFormat' put a breakpoint or a stop command in each part of the If statement to watch the code then try it. HTH Philip "Peter Rooney" wrote: Apologies to those of you who've already picked this up in the Excel forum. Can anyone see the deliberate error with this code - no matter what button I click, it always processes the vbYes option. Response returns "7" when i click "No" and "6" when I click "Yes". All help gratefuly received! :-) Sub ConfirmIssuesDelete() Dim Prompt, Buttons, Title, Help, Ctxt, Response, MyString Prompt = "Do you REALLY want to delete this row?" ' Message. Buttons = vbYesNo + vbCritical + vbDefaultButton1 ' Buttons. Title = "Whoa!" ' Title. Help = "D:\DEMO.TXT" ' Define Help file. Ctxt = 1000 ' Define topic Response = MsgBox(Prompt, Buttons, Title, Help, Ctxt) MsgBox (Response) If Response = vbYes Then WhereWasI = (Selection.Address) Selection.EntireRow.Delete IssuesDataRangeFormat Range(WhereWasI).Select Else Exit Sub End If End Sub |
VbYesNo MsgBox won't respond to "No"
Your code works for me. vbYes and vbNo are symbolic constants
that resolve to 6 and 7, respectively. The MsgBox is returning the correct value for both yes and no replies. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Peter Rooney" wrote in message ... Apologies to those of you who've already picked this up in the Excel forum. Can anyone see the deliberate error with this code - no matter what button I click, it always processes the vbYes option. Response returns "7" when i click "No" and "6" when I click "Yes". All help gratefuly received! :-) Sub ConfirmIssuesDelete() Dim Prompt, Buttons, Title, Help, Ctxt, Response, MyString Prompt = "Do you REALLY want to delete this row?" ' Message. Buttons = vbYesNo + vbCritical + vbDefaultButton1 ' Buttons. Title = "Whoa!" ' Title. Help = "D:\DEMO.TXT" ' Define Help file. Ctxt = 1000 ' Define topic Response = MsgBox(Prompt, Buttons, Title, Help, Ctxt) MsgBox (Response) If Response = vbYes Then WhereWasI = (Selection.Address) Selection.EntireRow.Delete IssuesDataRangeFormat Range(WhereWasI).Select Else Exit Sub End If End Sub |
VbYesNo MsgBox won't respond to "No"
Philip,
Doh! It doesn't help if the calling macro deletes the row anyway... Sorry to waste your time - have a great Christmas! :-) Pete "Philip" wrote: it works fine in Excel 2000 after I declared 'WhereWasI' and commented 'IssuesDataRangeFormat' put a breakpoint or a stop command in each part of the If statement to watch the code then try it. HTH Philip "Peter Rooney" wrote: Apologies to those of you who've already picked this up in the Excel forum. Can anyone see the deliberate error with this code - no matter what button I click, it always processes the vbYes option. Response returns "7" when i click "No" and "6" when I click "Yes". All help gratefuly received! :-) Sub ConfirmIssuesDelete() Dim Prompt, Buttons, Title, Help, Ctxt, Response, MyString Prompt = "Do you REALLY want to delete this row?" ' Message. Buttons = vbYesNo + vbCritical + vbDefaultButton1 ' Buttons. Title = "Whoa!" ' Title. Help = "D:\DEMO.TXT" ' Define Help file. Ctxt = 1000 ' Define topic Response = MsgBox(Prompt, Buttons, Title, Help, Ctxt) MsgBox (Response) If Response = vbYes Then WhereWasI = (Selection.Address) Selection.EntireRow.Delete IssuesDataRangeFormat Range(WhereWasI).Select Else Exit Sub End If End Sub |
VbYesNo MsgBox won't respond to "No"
Chip,
Thanks for replying - as you so rightly pointed out, there's nothing wrong with this code - the calling macro was deleting the row anyway after the subroutine had been called. Well, it IS nearly holiday time! Have a great Christmas and thanks for your help throughout the year! :-) Pete "Chip Pearson" wrote: Your code works for me. vbYes and vbNo are symbolic constants that resolve to 6 and 7, respectively. The MsgBox is returning the correct value for both yes and no replies. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Peter Rooney" wrote in message ... Apologies to those of you who've already picked this up in the Excel forum. Can anyone see the deliberate error with this code - no matter what button I click, it always processes the vbYes option. Response returns "7" when i click "No" and "6" when I click "Yes". All help gratefuly received! :-) Sub ConfirmIssuesDelete() Dim Prompt, Buttons, Title, Help, Ctxt, Response, MyString Prompt = "Do you REALLY want to delete this row?" ' Message. Buttons = vbYesNo + vbCritical + vbDefaultButton1 ' Buttons. Title = "Whoa!" ' Title. Help = "D:\DEMO.TXT" ' Define Help file. Ctxt = 1000 ' Define topic Response = MsgBox(Prompt, Buttons, Title, Help, Ctxt) MsgBox (Response) If Response = vbYes Then WhereWasI = (Selection.Address) Selection.EntireRow.Delete IssuesDataRangeFormat Range(WhereWasI).Select Else Exit Sub End If End Sub |
All times are GMT +1. The time now is 08:27 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com