banner



How To Create Sound Alert In Excel

Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Conditionally Making a Sound.

Conditionally Making a Sound

Ken knows how to create conditional formats in Excel. What he really wants to do, however, is have Excel make an audible sound (a beep or whatever) if the conditions are met.

There is no way to do this without resorting to using macros. If you just want to make a beep sound, you can use something like this:

Function BeepMe() As String     Beep     BeepMe = "" End Function        

All this user-defined function does is to play a sound (which will vary depending on the system you are using) and then return an empty string. You can use the function in your worksheet in this manner:

=IF(A12>300,BeepMe(),"")        

If you want to play some sound other than the default system beep, you'll need to use the Windows API PlaySound function. The following code creates a user-defined function that will play the default "tada" sound so prevalent in Windows.

Private Declare Function PlaySound Lib "winmm.dll" _   Alias "PlaySoundA" (ByVal lpszName As String, _   ByVal hModule As Long, ByVal dwFlags As Long) As Long      Const SND_SYNC = &H0     Const SND_ASYNC = &H1     Const SND_FILENAME = &H20000  Function SoundMe() As String     Call PlaySound("c:\windows\media\tada.wav", _       0, SND_ASYNC Or SND_FILENAME)     SoundMe = "" End Function        

This function can be called the same as the previous example:

=IF(A12>300,SoundMe(),"")        

If you want to play a different WAV file, simply change the file specification in the SoundMe function.

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (7658) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Conditionally Making a Sound.

Author Bio

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. Learn more about Allen...

MORE FROM ALLEN

Viewing Formula Results

When editing information in a cell, you may need to know the result of a portion of your formula. The shortcut described ...

Discover More

Backwards Date Parsing

Enter information into a worksheet, and you come to anticipate (and count on) how Excel will interpret that information ...

Discover More

Sorting Decimal Values

Government and industrial organizations often use a numbering system that relies upon a number both before and after a ...

Discover More

How To Create Sound Alert In Excel

Source: https://excel.tips.net/T007658_Conditionally_Making_a_Sound.html

Posted by: doranspold1936.blogspot.com

0 Response to "How To Create Sound Alert In Excel"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel