Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
vbOKCancel box to close
Hi,
I've put in a vbOKCancel box into my macro and all I want it to do is: If you select Ok continue with the macro if you select Cancel I want the macro to finsh, so I have put: MsgBox strName & " - Is The Latest File - " & varDate, vbOKCancel If answer = vbCancel Then Exit Sub Else Call OpenMost End If However when I step through the macro to see if its working when I click Cancel it skips over the exit sub command and continues with the rest of the macro. So at the moment it doesn't matter which button I press the macro goes all the way through to the end. Am I missing something simple? can anyone advise? Many Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
vbOKCancel box to close
If MsgBox(strName & " - Is The Latest File - " & varDate, vbOKCancel) =
vbCancel Then Exit Sub End If Call OpenMost or answer = MsgBox(strName & " - Is The Latest File - " & varDate, vbOKCancel) If answer = vbCancel Then Exit Sub Else Call OpenMost End If -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) wrote in message ps.com... Hi, I've put in a vbOKCancel box into my macro and all I want it to do is: If you select Ok continue with the macro if you select Cancel I want the macro to finsh, so I have put: MsgBox strName & " - Is The Latest File - " & varDate, vbOKCancel If answer = vbCancel Then Exit Sub Else Call OpenMost End If However when I step through the macro to see if its working when I click Cancel it skips over the exit sub command and continues with the rest of the macro. So at the moment it doesn't matter which button I press the macro goes all the way through to the end. Am I missing something simple? can anyone advise? Many Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
vbOKCancel box to close
You need to check the return value from MsgBox()
If Msgbox (....) =vbOK Then 'Do your stuff End End Sub NickHK wrote in message ps.com... Hi, I've put in a vbOKCancel box into my macro and all I want it to do is: If you select Ok continue with the macro if you select Cancel I want the macro to finsh, so I have put: MsgBox strName & " - Is The Latest File - " & varDate, vbOKCancel If answer = vbCancel Then Exit Sub Else Call OpenMost End If However when I step through the macro to see if its working when I click Cancel it skips over the exit sub command and continues with the rest of the macro. So at the moment it doesn't matter which button I press the macro goes all the way through to the end. Am I missing something simple? can anyone advise? Many Thanks |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
vbOKCancel box to close
Thanks Guys,
Worked a treat. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
changing vbOKCancel button title | Excel Discussion (Misc queries) | |||
Exiting Sub when Selecting Cancel on vbOKCancel | Excel Discussion (Misc queries) | |||
Excel shoud not close all active books when clicking close button | Excel Discussion (Misc queries) | |||
excel - Windows close button (x) should only close active workboo. | Setting up and Configuration of Excel | |||
Qn: vbOKCancel -- Cancel doesn't work?? | Excel Programming |