Play Sound in Excel Automatically Using VBA Macro @Exceltrainingvideos
Play Sound in Excel Automatically Using VBA Macro  @Exceltrainingvideos
Uploaded January 2022 | Updated September 2026, 2 weeks ago
How to play a sound in Excel with a macro or VBA code to warn us, for example, of a wrong data entry. More details available on our website: exceltrainingvideos.com/play-sound-in-excel-automatically-with-vba

Here's the complete macro code:
Option Explicit

Private Declare PtrSafe Function sndPlaySound32 Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Private Sub Worksheet_Change(ByVal Target As Range)
Dim highestGST As Long

highestGST = 28

If Range("B2").Value GREATER THAN highestGST Then

Call sndPlaySound32("C:\windows\media\Windows Error.wav", 1)

End If

End Sub

Private Declare PtrSafe Function sndPlaySound32 Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Sub PlaySound()
Dim lastrow As Long, i As Long

lastrow = Application.WorksheetFunction.CountA(Sheet1.Range("B:B"))

MsgBox lastrow

For i = 2 To lastrow
If Cells(i, 2) GREATER THAN 28 Then Call sndPlaySound32("C:\Windows\Media\Windows Exclamation.wav", &H8)
Next i

End Sub

NOTE: Replace GREATER THAN with an angular sign.
Play Sound in Excel Automatically Using VBA MacroFree Date and Time Picker Add-InCreate Folders and Files AutomaticallyInsert Hyperlink Automatically YouTube ShortsWhatsapp Desktop Automation with VBAFind Specific Word in TextClean Data Using Flash Fill in ExcelAPIs in Excel. No VBA. Use Power Query.Text To Columns Using Macro in ExcelCopy Charts from Excel to PowerPoint Automatically2021 | Shorts | Quick Inventory Management No VBAWhat is  Modeless UserForm
Dinesh Kumar Takyar |

Play Sound in Excel Automatically Using VBA Macro

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER