Worksheet Formula to Beep and Display an Alert Box (86011)
The information in this article applies to:
- Microsoft Excel for Windows 95
- Microsoft Excel for Windows 5.0
- Microsoft Excel for Windows NT 5.0
- Microsoft Excel for Windows 4.0a
- Microsoft Excel for Windows 3.0
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("USER.EXE","MessageBeep",">H",0)+CALL("USER
.EXE","MessageBox","HHCCH",0,"MESSAGE","TITLE",),""),"")
32-bit versions of Microsoft Excel (5.0 for Windows NT, 7.0)
------------------------------------------------------------
=IF(CONDITION,TEXT(CALL("USER32","MessageBeep",">H",0)+CALL("USER32",
"MessageBoxA","HHCCH",0,"MESSAGE","TITLE",),""),"")
Where:
- CONDITION is a valid conditional statement, such as A1>5.
- "MESSAGE" is a text string which will appear inside the alert box
that will be displayed when the condition is met.
- "TITLE" 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.
REFERENCES
"Microsoft Excel Function Reference," version 3.0, pages 24-25,
125-126 and 234-235
"Microsoft Excel Function Reference," version 4.0, pages 42-43,
225-226 and 431-432
Microsoft Windows Software Developers Kit
Modification Type: | Minor | Last Reviewed: | 8/15/2005 |
---|
Keywords: | KB86011 |
---|
|