Microsoft KB Archive/86011

= Worksheet Formula to Beep and Display an Alert Box =

Article ID: 86011

Article Last Modified on 11/16/2006

-

APPLIES TO


 * Microsoft Excel 95 Standard Edition
 * Microsoft Excel 5.0 Standard Edition
 * Microsoft Excel 5.0 Standard Edition
 * Microsoft Excel 4.0a
 * Microsoft Excel 3.0 Standard Edition

-



This article was previously published under Q86011



SUMMARY
The following formulas, when entered on a spreadsheet, will produce a beep and display an alert box if the specified condition occurs.

  16-bit versions of Microsoft Excel (3.x, 4.x, 5.x for Windows) --  =IF(CONDITION,TEXT(CALL(&quot;USER.EXE&quot;,&quot;MessageBeep&quot;,&quot;>H&quot;,0)+CALL(&quot;USER   .EXE&quot;,&quot;MessageBox&quot;,&quot;HHCCH&quot;,0,&quot;MESSAGE&quot;,&quot;TITLE&quot;,),&quot;&quot;),&quot;&quot;)

32-bit versions of Microsoft Excel (5.0 for Windows NT, 7.0) =IF(CONDITION,TEXT(CALL(&quot;USER32&quot;,&quot;MessageBeep&quot;,&quot;>H&quot;,0)+CALL(&quot;USER32&quot;,  &quot;MessageBoxA&quot;,&quot;HHCCH&quot;,0,&quot;MESSAGE&quot;,&quot;TITLE&quot;,),&quot;&quot;),&quot;&quot;)

Where:


 * CONDITION is a valid conditional statement, such as A1>5.
 * &quot;MESSAGE&quot; is a text string which will appear inside the alert box that will be displayed when the condition is met.
 * &quot;TITLE&quot; is a text string which will appear inside the title bar of the alert box that will be displayed when the condition is met.



MORE INFORMATION
The CALL statements call routines are part of the Windows DLL files USER.EXE (16-bit) and USER32.DLL (32-bit). Because the CALL statement can be used in this form on a Microsoft Excel worksheet it is not necessary to use a macro sheet or Visual Basic module.

The message in the alert box may contain multiple lines by typing the first line of MESSAGE text and then pressing ENTER while holding down the ALT key.

