Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Close Message box after 3 seconds | Excel Programming | |||
Automatically close a message box | Excel Programming | |||
Warning message on file close | Excel Worksheet Functions | |||
Force a Message Box to close unanswered | Excel Programming | |||
Close a message box | Excel Programming |