Return Value of Canceled Dialog Box in Excel

Last reviewed: November 2, 1994
Article ID: Q32867
The information in this article applies to:
  • Microsoft Excel for Windows, versions 2.x, 3.0, 4.0, 5.0
  • Microsoft Excel for OS/2, versions 2.2, and 3.0

SUMMARY

When a custom dialog box is terminated with the Cancel button, the value returned by the dialog box function is FALSE. The value will be returned on the macro sheet in the cell containing the dialog box function, not in the init/result column for the Cancel button in the dialog box definition area.

MORE INFORMATION

To perform additional processing based on whether or not the Cancel or OK button was pressed in the dialog box, interrogate the =DIALOG.BOX() statement in the macro using an IF() statement such as the following, where Cell A2 contains =DIALOG.BOX() and Cells A24 and B34 are other statements in a macro or subroutines:

   =IF(A2<>false,GOTO(A24),GOTO(B34))

This statement will cause the control of the macro to jump to Cell A24 and continue executing if the OK button is pressed in the dialog box, or to jump to Cell B34 if the Cancel button is pressed.

REFERENCES

"Microsoft Excel Function Reference," version 3.0, pages 57-58

"Microsoft Excel User's Guide," version 3.0, pages 634-635


KBCategory: kbusage
KBSubcategory:

Additional words: 2.0 2.00 2.01 2.1 2.10 2.2 2.20 2.21 3.0 3.00
4.0 4.00 5.0 5.00


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 2, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.