Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default 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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
NEW QUEST/REQ in "How to Reverse Contents ..." Pls Respond? TIA 3kings Excel Worksheet Functions 0 September 13th 07 05:14 PM
Best way to trap error to MsgBox "Too many cell formats" [email protected] Excel Discussion (Misc queries) 0 August 22nd 06 09:52 PM
VBYesNo MsgBox - Computer always says "Yes" Peter Rooney Excel Discussion (Misc queries) 4 December 22nd 05 02:42 PM
excel.application.run macro1 -- added code to respond "yes" to a inputbox Michael Joe Excel Programming 3 August 13th 04 10:11 PM


All times are GMT +1. The time now is 08:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"