If you wanted to hear an audio alert when your data in Excel reaches certain values, then see how you can make an alarm in Excel and activate it.
Excel spreadsheets allow you to have an immediate visual display of its cell values. You can, for example, use conditional formatting in Excel to change the color of a cell accordingly with his price.
Although a visual indication is useful, when the cell in question is on another sheet or outside the current window view, then you are not going to notice the change. Wouldn't it be useful if you could have Excel make a sound when certain criteria are met?
It can be done but you will need to dive into the world of Visual Basic to do it. Fortunately, you won't need any programming skills for this. You can simply follow the example below.
How to play a system sound to trigger an alarm in Excel
You can make Excel play a system sound with just a few lines of Visual Basic. You can then trigger that sound based on a cell's value.
To play a system sound in Excel:
Step 1: Open Excel and start Microsoft Visual Basic for Applications using the keyboard shortcut Alt + F11.
Step 2: Go to the selection Insert > Module.
Step 3: Enter the following code:
Function MakeABeep() as String
Beep
MakeABeep = “”
End Function
Step 4: Click the Save icon.
Step 5: Click on the drop down menu Save as: (Save as Type) and select Excel workbook with macros (Excel Macro-Enabled Workbook) . Your file must be saved in this format for the audio to play.
Step 6: Save your workbook.
Step 7: Close the Microsoft Visual Basic for Applications window by clicking the X in the upper-right corner of the window.
Step 8: To test your beep, type the following into any cell: =MakeABeep()
If you press Enter you will hear a system sound.
How to play a custom sound in Excel using Visual Basic
You can also set Excel to play a specific sound file if you prefer to choose your own sound instead of playing the system default sound.
To play a custom sound in Excel
Step 1: Start Microsoft Visual Basic for Applications by pressing Alt+F11.
Step 2: Click Insert > Module.
Step 3: Enter the following code:
#If Win64 Then
Private Declare PtrSafe Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As LongPtr, ByVal dwFlags As Long) As Boolean
#Else
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Boolean
#End If
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
Function AlarmSound() As String
Call PlaySound("C:\iguru\dimitris\alarm.wav", _
0, SND_ASYNC Or SND_FILENAME)
AlarmSound = ""
End Function
Replace “C:\iguru\dimitris\alarm.wav” with the file location of the audio file you want to use.
Step 4: Close the Microsoft Visual Basic for Applications window.
Step 5: Test your audio by typing the following into any cell: =AlarmSound()
Press Enter and your audio will play.
How to activate an alarm in Excel
Now that you have set the beep or alarm sound, the last stage is to activate these sounds when needed.
There are many different ways you can choose to activate your alarm. Here's an example of how to use your sound in an IF statement.
To play an alarm when a price reaches a certain level:
Step 1: Select an empty cell.
Step 2: Type: =IF(
Step 3: Click on the cell whose value you want to watch.
Step 4: Type: >
followed by the value you want to trigger the alarm.
Step 5: Now type one question mark and after makeaBeep() or AlarmSound().
Step 6: Type another one question mark and then type: "")
Step 7: Press Enter.
Now, when cell D2, which you're watching, gets a value greater than 100 (which you've set), your alarm will sound. You can test this by typing a value above your limit into the relevant cell.
Unleash the power of Excel
To learn how to trigger an alarm in Excel, you need to use Visual Basic. Using Visual Basic allows you to make Excel act far beyond its usual scope. However, it requires reasonable knowledge of the programming language and how it works with Excel.
Excel can also do many things without the need to use Visual Basic. You can write macros in Excel that will replay a series of actions. Once created, you can save your macros for use in other spreadsheets.
You can also create Excel formulas using the many built-in functions in Excel, such as VLOOKUP, TRUNC, or any of the many other useful functions.
