Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
NEW QUEST/REQ in "How to Reverse Contents ..." Pls Respond? TIA | Excel Worksheet Functions | |||
Best way to trap error to MsgBox "Too many cell formats" | Excel Discussion (Misc queries) | |||
VBYesNo MsgBox - Computer always says "Yes" | Excel Discussion (Misc queries) | |||
excel.application.run macro1 -- added code to respond "yes" to a inputbox | Excel Programming |