ALERT

Macro Sheets Only

Displays a dialog box and message and waits for you to choose a button. Use ALERT instead of MESSAGE if you want to interrupt the flow of a macro and force the user to make a choice or to notice an important message.

Syntax

ALERT(message_text, type_num, help_ref)

Message_text is the message displayed in the dialog box.

Type_num is a number from 1 to 3 specifying which type of dialog box to display. If you omit type_num, it is assumed to be 2.

Help_ref is a reference to a custom online Help topic, in the form "filename! topic_number".

Note In Microsoft Excel for the Macintosh, the ALERT dialog box is not a movable window.

Examples

The following dialog boxes show the results of using ALERT with type_num 1, 2, and 3. The first and fourth examples include a Help button.

In Microsoft Excel for Windows, the following macro formulas display these three dialog boxes.


ALERT("Are you sure you want to delete this item?", 1, "CUSTHELP.HLP!101")


ALERT("The number should be between 1 and 100", 2)


ALERT("Your debits and credits are not equal; do not end this transaction.", 3)

In Microsoft Excel for the Macintosh, the following macro formulas display these three dialog boxes.


ALERT("Are you sure you want to delete this item?", 1, "'Custom Help'!101")


ALERT("The number should be between 1 and 100", 2)


ALERT("Your debits and credits are not equal; do not end this transaction.", 3)

A common use of the ALERT function is to give the user a choice of two actions. The following macro formula in an Auto_Open macro asks which reference style to use when the worksheet is opened.


A1.R1C1(ALERT("Click OK for A1 style; Cancel for R1C1", 1))

Related Functions

INPUT Displays a dialog box for user input

MESSAGE Displays a message in the status bar

List of Customizing Functions