+ Reply to Thread
Results 1 to 5 of 5

VBYesNo MsgBox - Computer always says "Yes"

  1. #1
    Peter Rooney
    Guest

    VBYesNo MsgBox - Computer always says "Yes"

    Good afternoon, all!

    Apologies for those non UK residents who didn't get the "Little Britain"
    joke...

    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. #2
    Ron Coderre
    Guest

    RE: VBYesNo MsgBox - Computer always says "Yes"

    Try changing your code to this:

    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

    If MsgBox(Prompt, Buttons, Title, Help, Ctxt) = vbYes Then
    WhereWasI = (Selection.Address)
    Selection.EntireRow.Delete
    IssuesDataRangeFormat
    Range(WhereWasI).Select
    Else
    Exit Sub
    End If


    Does that help?

    ***********
    Regards,
    Ron

    XL2002, WinXP-Pro


    "Peter Rooney" wrote:

    > Good afternoon, all!
    >
    > Apologies for those non UK residents who didn't get the "Little Britain"
    > joke...
    >
    > 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. #3
    Peter Rooney
    Guest

    RE: VBYesNo MsgBox - Computer always says "Yes"

    Ron,

    Thanks, but for some bizarre reason, it disn't - it still deleted the row
    even when I clicked "No"
    I also realise that I should have posted this in the developers' forum, so
    special thanks for responding!

    Cheers

    Pete



    "Ron Coderre" wrote:

    > Try changing your code to this:
    >
    > 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
    >
    > If MsgBox(Prompt, Buttons, Title, Help, Ctxt) = vbYes Then
    > WhereWasI = (Selection.Address)
    > Selection.EntireRow.Delete
    > IssuesDataRangeFormat
    > Range(WhereWasI).Select
    > Else
    > Exit Sub
    > End If
    >
    >
    > Does that help?
    >
    > ***********
    > Regards,
    > Ron
    >
    > XL2002, WinXP-Pro
    >
    >
    > "Peter Rooney" wrote:
    >
    > > Good afternoon, all!
    > >
    > > Apologies for those non UK residents who didn't get the "Little Britain"
    > > joke...
    > >
    > > 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. #4
    Ron Coderre
    Guest

    RE: VBYesNo MsgBox - Computer always says "Yes"

    I'm not sure why that is happening....it works fine when I run it.

    I'm guessing that some other code is causing the problem.

    Here's a simple way to find out:

    If MsgBox(Prompt, Buttons, Title, Help, Ctxt) = vbYes Then
    MsgBox "You clicked yes"
    ' WhereWasI = (Selection.Address)
    ' Selection.EntireRow.Delete
    ' IssuesDataRangeFormat
    ' Range(WhereWasI).Select
    Else
    MsgBox "You clicked no"
    Exit Sub
    End If

    Does that help?
    ***********
    Regards,
    Ron

    XL2002, WinXP-Pro


    "Peter Rooney" wrote:

    > Ron,
    >
    > Thanks, but for some bizarre reason, it disn't - it still deleted the row
    > even when I clicked "No"
    > I also realise that I should have posted this in the developers' forum, so
    > special thanks for responding!
    >
    > Cheers
    >
    > Pete
    >
    >
    >
    > "Ron Coderre" wrote:
    >
    > > Try changing your code to this:
    > >
    > > 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
    > >
    > > If MsgBox(Prompt, Buttons, Title, Help, Ctxt) = vbYes Then
    > > WhereWasI = (Selection.Address)
    > > Selection.EntireRow.Delete
    > > IssuesDataRangeFormat
    > > Range(WhereWasI).Select
    > > Else
    > > Exit Sub
    > > End If
    > >
    > >
    > > Does that help?
    > >
    > > ***********
    > > Regards,
    > > Ron
    > >
    > > XL2002, WinXP-Pro
    > >
    > >
    > > "Peter Rooney" wrote:
    > >
    > > > Good afternoon, all!
    > > >
    > > > Apologies for those non UK residents who didn't get the "Little Britain"
    > > > joke...
    > > >
    > > > 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. #5
    Peter Rooney
    Guest

    RE: VBYesNo MsgBox - Computer always says "Yes"

    Ron,

    Doh! You were right - it doesn't help if the celling macro deletes the row
    anyway...

    Sorry to waste your time - have a great Christmas! :-)

    Pete



    "Ron Coderre" wrote:

    > I'm not sure why that is happening....it works fine when I run it.
    >
    > I'm guessing that some other code is causing the problem.
    >
    > Here's a simple way to find out:
    >
    > If MsgBox(Prompt, Buttons, Title, Help, Ctxt) = vbYes Then
    > MsgBox "You clicked yes"
    > ' WhereWasI = (Selection.Address)
    > ' Selection.EntireRow.Delete
    > ' IssuesDataRangeFormat
    > ' Range(WhereWasI).Select
    > Else
    > MsgBox "You clicked no"
    > Exit Sub
    > End If
    >
    > Does that help?
    > ***********
    > Regards,
    > Ron
    >
    > XL2002, WinXP-Pro
    >
    >
    > "Peter Rooney" wrote:
    >
    > > Ron,
    > >
    > > Thanks, but for some bizarre reason, it disn't - it still deleted the row
    > > even when I clicked "No"
    > > I also realise that I should have posted this in the developers' forum, so
    > > special thanks for responding!
    > >
    > > Cheers
    > >
    > > Pete
    > >
    > >
    > >
    > > "Ron Coderre" wrote:
    > >
    > > > Try changing your code to this:
    > > >
    > > > 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
    > > >
    > > > If MsgBox(Prompt, Buttons, Title, Help, Ctxt) = vbYes Then
    > > > WhereWasI = (Selection.Address)
    > > > Selection.EntireRow.Delete
    > > > IssuesDataRangeFormat
    > > > Range(WhereWasI).Select
    > > > Else
    > > > Exit Sub
    > > > End If
    > > >
    > > >
    > > > Does that help?
    > > >
    > > > ***********
    > > > Regards,
    > > > Ron
    > > >
    > > > XL2002, WinXP-Pro
    > > >
    > > >
    > > > "Peter Rooney" wrote:
    > > >
    > > > > Good afternoon, all!
    > > > >
    > > > > Apologies for those non UK residents who didn't get the "Little Britain"
    > > > > joke...
    > > > >
    > > > > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1