Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default Message box & close worksheet

Code bolow doesn't close the worksheet when 'no' is chosen rather than yes.
Any ideas?
Private Sub CommandButton1_Click()

MsgBox("Do you wish to order another item?", _
vbYesNo)

If response = vbYes Then
If vbYes Then
TextBox3.SetFocus
Else
ThisWorkbook.Close True
End If
End If

End Sub
--
tia

Jock
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Message box & close worksheet

Jock,

Try this :-

Private Sub CommandButton1_Click()
response = MsgBox("Do you wish to order another item?", vbYesNo)
If response = vbYes Then
MsgBox ("YES")
'TextBox3.SetFocus
Else
ThisWorkbook.Close savechanges:=True
End If
End Sub

Mike

"Jock" wrote:

Code bolow doesn't close the worksheet when 'no' is chosen rather than yes.
Any ideas?
Private Sub CommandButton1_Click()

MsgBox("Do you wish to order another item?", _
vbYesNo)

If response = vbYes Then
If vbYes Then
TextBox3.SetFocus
Else
ThisWorkbook.Close True
End If
End If

End Sub
--
tia

Jock

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Message box & close worksheet

Hi Jock
The code does not work since your are using a variable which has no value
attached.
You may consider amending:

Private Sub CommandButton1_Click()

response = MsgBox("Do you wish to order another item?", _
vbYesNo)

If response = vbYes Then
TextBox3.SetFocus
Else
ThisWorkbook.Close True
End If
End If
End Sub

HTH
Cordially
Pascal


"Jock" a écrit dans le message de news:
...
Code bolow doesn't close the worksheet when 'no' is chosen rather than
yes.
Any ideas?
Private Sub CommandButton1_Click()

MsgBox("Do you wish to order another item?", _
vbYesNo)

If response = vbYes Then
If vbYes Then
TextBox3.SetFocus
Else
ThisWorkbook.Close True
End If
End If

End Sub
--
tia

Jock



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Message box & close worksheet



try this:


Private Sub CommandButton1_Click()

Dim response

response = MsgBox("Do you wish to order another item?", vbYesNo)

If response = vbYes Then

TextBox3.SetFocus
exit sub
Else

ThisWorkbook.Close True

End If


End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Message box & close worksheet

hi Jock

You could do like this

Private Sub CommandButton1_Click()

Response = MsgBox("Do you wish to order another item?", vbYesNo)

If Response = vbYes Then
TextBox3.SetFocus
Else
ThisWorkbook.Close
End If

End Sub


hope it helps

S




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Message box & close worksheet

Jock,

Private Sub CommandButton1_Click()
Dim Response as long

Response = MsgBox("Do you wish to order another item?", vbYesNo)

If response = vbYes Then
TextBox3.SetFocus
Else
ThisWorkbook.Close True
End If

End Sub

Also, check the Help for "Option Explicit".

NickHK

"Jock" wrote in message
...
Code bolow doesn't close the worksheet when 'no' is chosen rather than

yes.
Any ideas?
Private Sub CommandButton1_Click()

MsgBox("Do you wish to order another item?", _
vbYesNo)

If response = vbYes Then
If vbYes Then
TextBox3.SetFocus
Else
ThisWorkbook.Close True
End If
End If

End Sub
--
tia

Jock



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default Message box & close worksheet

Many thanks to Mike, Papou, Nick, Snake and Incedental. Job done
Snake, "I heard you were dead" Much better now, I see.lol
--
tia

Jock


"Jock" wrote:

Code bolow doesn't close the worksheet when 'no' is chosen rather than yes.
Any ideas?
Private Sub CommandButton1_Click()

MsgBox("Do you wish to order another item?", _
vbYesNo)

If response = vbYes Then
If vbYes Then
TextBox3.SetFocus
Else
ThisWorkbook.Close True
End If
End If

End Sub
--
tia

Jock

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Message box & close worksheet

| Snake, "I heard you were dead" Much better now, I see.lol

the rumours about my death were obviously false :D


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
Close Message box after 3 seconds blackbox via OfficeKB.com Excel Programming 8 June 21st 07 03:00 PM
Automatically close a message box ed Excel Programming 3 October 31st 06 05:58 PM
Warning message on file close Lambtwo Excel Worksheet Functions 1 October 25th 05 03:31 AM
Force a Message Box to close unanswered jennie Excel Programming 1 October 12th 05 10:23 AM
Close a message box Nigel Excel Programming 1 September 15th 05 12:49 AM


All times are GMT +1. The time now is 02:11 AM.

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"