Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Peter Rooney
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.misc
Ron Coderre
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.misc
Peter Rooney
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.misc
Ron Coderre
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.misc
Peter Rooney
 
Posts: n/a
Default 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
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 /vba / computer IP address jolipe Excel Discussion (Misc queries) 1 June 3rd 05 10:55 PM
Can I install Office 97 on my new windows xp computer? whitedog Excel Discussion (Misc queries) 3 June 3rd 05 03:36 PM
Msgbox Wildman Excel Worksheet Functions 1 April 26th 05 04:57 AM
HOW TO TRANSFER AUTOCORRECT DICTIONARY TO NEW COMPUTER?? ALAN K Setting up and Configuration of Excel 1 February 17th 05 09:34 PM
Autocomplete works with my home computer but not the office computer Andy Excel Discussion (Misc queries) 4 December 11th 04 07:21 PM


All times are GMT +1. The time now is 04:28 PM.

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

About Us

"It's about Microsoft Excel"