3 Ways to Ring an Alarm in Microsoft Excel

If you learn how to ring an alarm in Excel you can get audio notifications when a cell or cell range meets a condition that you’ve set.

Imagine a scenario where critical deadlines loom, and you need a gentle nudge or a loud bell to draw attention to impending tasks. For this, you might choose to set up a reminder on your mobile phone or Outlook Calendar.

When you go to a different software from your Excel worksheet, you get distracted and get a hit on productivity. Why don’t you set up the reminder in Excel? Now, you might say there isn’t any Excel feature for a reminder alarm. That’s partially true!

You can use Excel VBA to create custom beep or alarm sound functions. Then, you can use that function in various formulas like IF or Conditional Formatting rules to sound an alarm.

I’m writing below various Excel VBA scripts to ring an alarm in Excel. I’ll also portray various scenarios where you can apply this skill.

Can Excel Ring an Alarm?

You can use various Conditional Formatting rules to highlight cells or cell ranges when they meet pre-set criteria. This might work as a visual reminder but there aren’t any ribbon menu buttons to set up audio notifications in Microsoft Excel. Excel doesn’t allow you to play any audio using its user interface buttons as you do on desktop reminder apps like Any.do, TickTick, Todoist, etc.

However, you can program Excel using Visual Basic for Applications (VBA) programming language Sub Routines, Function Procedures, Objects, etc. VBA has multiple function procedures to play an audio file or directly sound a beep alarm. For example, PlaySound, Beep, and sndPlaySound.

Therefore, you can write a VBA script in Excel to ring a default beep alarm or play custom notification audio using WAV files from your PC.

Create a Custom Function to Play System Alert

The most basic way to ring an alarm in Excel is by creating a custom beep formula that you can use in other formulas like IF. So, Excel will play the default beep sound when the cell meets an IF condition.

VBA script to ring an alarm
VBA script to ring an alarm

Open the Excel VBA Editor from Developer > Code commands block. Click Insert and choose Module to open a blank module where you can write VBA scripts. Now, copy and paste the following script into the blank module:

Function CustomBeep()
    ' Play a beep sound
    Beep
End Function
Microsoft Excel dialog
Microsoft Excel dialog

Now, click the Save button on the Excel VBA Editor toolbar and choose No on the Microsoft Excel dialog box that pops up.

Save as dialog
Save as dialog

Click the Save as type drop-down list on the Save As dialog and choose the XLSM file type option.

Finally, click the Save button to save the VBA script as a VBA macro that you can call anytime using the CustomBeep() syntax when creating formulas or by pressing Alt + F8 and running the CustomBeep macro.

Now that you’ve created the CustomBeep() function in Excel to ring the Windows default notification sound, find below a scenario where you can use this function:

Example stock monitoring sheet
Example stock monitoring sheet

The above is a stock price monitoring worksheet screenshot. I’m importing real-time market data when the trading begins.

The formatting goal
The formatting goal

The aim here is to keep the worksheet open and work on other apps or Excel workbooks. If the price of a stock hits the target sell price, the Excel worksheet will sound the default Windows alert and show a Sell notification in green fill color.

In D2, I used the following formula to show a text string Sell and play the Windows default alert sound.

=IF(B2>1750,CustomBeep(),"Waiting")

The above formula is self-explanatory. However, if you’re curious about the availability of the CustomBeep() formula in Excel, no worries. You can create it by following the VBA macro-method mentioned earlier.

Customizing the Beep Alarm

If you don’t like the default Windows alert, here’s how you can choose a different one:

Change system sound
Change system sound
  1. Click the Start menu and type Sound.
  2. The Change system sound option will show as the top search result. Click on that.
Sound dialog
Sound dialog
  1. You shall see the Sound dialog box.
  2. Click on the Asterisk sound inside the Program Events menu.
  3. Now, click on the Sounds drop-down list.
  4. A list of available Windows sounds shall open.
  5. Choose the sound you like. For example, Alarm10.wav.
Customizing sound
Customizing sound
  1. Click on the Apply button and hit OK to set Alarm10.wav as the default Windows system alert.
  2. Now, if you run the CustomBeep macro, the new sound will play instead of the default beep.

Tips for Using the Beep Function in VBA

  • You’ll not hear the beep alert if the Windows system sound is muted.
No sounds
No sounds
  • If you’ve set up the Windows system alert as No Sounds in the Sound dialog, the VBA macro won’t work.
  • The name of the macro must start with something else other than Beep. For example, you can use CustomBeep, PlayBeep, etc. If you name it Beep, the macro won’t work.

So, if you face any issues with this Excel VBA macro, check for the above settings first.

Ring an Alarm Using a Different Audio File

If you’d like to use a completely different audio file, you can use the following Excel VBA script:

A VBA script to ring a custom audio file
A VBA script to ring a custom audio file
#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:\Users\Joe\Downloads\custombeep.wav", _
      0, SND_ASYNC Or SND_FILENAME)
    AlarmSound = ""
End Function

Replace the existing file address in the Call PlaySound function using your own audio file’s directory address, like: C:\Users\Joe\Downloads\custombeep.wav.

Ring an Alarm as a Reminder in Excel

If you work on Excel workbooks for many hours in your workday and forget important tasks like replying to an important email, paying utility bills, or taking a break, you can set up reminders directly on your Excel workbook.

Follow the steps mentioned earlier to create an Excel VBA module using the following script and go to the Save As dialog box:

Dim Alarm As Date
Dim Message As String

Sub PopupReminder()
    Dim When As String

    If Alarm = 0 Then
        When = InputBox("What time would you like the reminder message to Popup?")
        If When <> "" And When <> "False" Then
            Message = InputBox("Please enter the reminder message")
            On Error Resume Next
            Alarm = Date + TimeValue(When)
            On Error GoTo 0
            Application.OnTime Alarm, "PopupReminder"
        End If
    Else
        Beep
        If Message <> "" Then
            Application.Speech.Speak Message
            MsgBox Message
            Message = ""
            Alarm = 0
        End If
    End If
End Sub
Save as an add-in
Save as an add-in

On the Save As dialog, don’t choose the XLSM file. Instead, choose XLAM or Excel Add-in file type. Hit the Save button to save the Excel workbook along with the VBA macro as an Excel Add-in.

Add-ins command
Add-ins command

Now, close the existing workbook. Open a new Excel file, go to the Developer tab, and click on the Excel Add-ins button inside the Add-ins commands block.

Importing an add-in
Importing an add-in

On the Add-ins dialog, click the Browse button and navigate to the XLAM file that you’ve just saved on your PC. Select the file and click OK to import the add-in to your Excel app.

Activating an add-in
Activating an add-in

You should now see the XLAM file inside the Add-ins dialog. Checkmark the checkbox near this file and click OK. This Add-in will now become active on all Excel workbooks on your PC.

Customize ribbon
Customize ribbon

Now, press the Alt + F + T keys to open the Excel Options dialog. Go to the Customize Ribbon category on the left-side panel.

Adding macro to a group
Adding a macro to a group

Click on the Choose commands from drop-down and choose the Macros option. In the list, find and select the PopupReminder macro.

Now, select any tab from the Main Tabs list. Choose the Developer drop-down and add a New Group. Rename the group to a name you can remember.

Click on the New Group you just created and click on the Add button to insert the PopupReminder macro into the newly created group. Click OK to close the Excel Options dialog.

Reminder macro
Reminder macro

Now, open any Excel workbook, navigate to Developer > New Group (Formatting), and click on the PopupReminder macro.

This should trigger the reminder macro you created earlier. Enter a time of the day, like 12:38 AM, and a message that you want Excel to remind you, like “Take a break.”

The macro will sound a beep alarm when the system time reaches the time you entered in the VBA macro input box. Your PC will also read out the message so you don’t miss it anyway. At least one Excel workbook must be open in the background for the alarm and reminder to sound.

Conclusions

Ringing an alarm in Excel is an advanced skill. However, learning the skill is fairly easy if you follow the step-by-step instructions in this article.

For sure, your colleagues and classmates will admire your Excel expertise if you show off this Excel skill at work or school.

Did the article help? Do you know a better way to sound an alarm in Excel? Share your feedback by writing your comments in the box given below.

About the Author

Bipasha Nath

Bipasha Nath

Bipasha is a technical content writer with 10+ years of experience in the technology industry. She previously worked in a SaaS software development company focused on SharePoint, OneDrive, Word, Excel, Word solutions.

Subscribe

Subscribe for awesome Microsoft Excel videos 😃

Related Posts

Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get the Latest Microsoft Excel Tips

Follow Us

Follow us to stay up to date with the latest in Microsoft Excel!

Subscribe for awesome Microsoft Excel videos 😃