VbYesNo MsgBox won't respond to "No"

P

Peter Rooney

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
 
P

Philip

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
 
C

Chip Pearson

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


message
news:[email protected]...
 
P

Peter Rooney

Philip,

Doh! It doesn't help if the calling macro deletes the row anyway...

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

Pete
 
P

Peter Rooney

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top