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.
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.



![Whatsapp Desktop Automation with VBA
How to automate Whatsapp Desktop to login, search for user, send message and attachment and logout.
Heres the complete macro or VBA code:
Option Explicit
Dim driver As New WebDriver
Sub LoginSearchUserSendMessageAttachmentViaWhatsapp()
Chrome Driver
Selenium
Selenium Wrapper
Dim keys As New SeleniumWrapper.keys
Dim filepath As String
filepath = C:exceltrainingvideos-12find-header-with-todays-date.xlsm
driver.Start chrome
driver.Get https://web.whatsapp.com/
driver.Window.Maximize
driver.Wait 5000
driver.Wait 2000
driver.FindElementByXPath(//span[@title = Dt]).Click
driver.Wait 1000
driver.SendKeys (keys.Tab + keys.Tab)
driver.Wait 1000
driver.SendKeys (Poonam Mobile)
driver.Wait 1000
driver.SendKeys (keys.Enter)
driver.FindElementByClass (_3FRCZ)
driver.SendKeys (Please study *the below attached file* for the class tomorrow.)
driver.Wait 1000
driver.SendKeys (keys.Enter)
driver.Wait 2000
driver.FindElementByXPath(//div[@title=Attach]).Click
driver.Wait 10000
driver.FindElementByXPath(//input[@accept=image/*,video/mp4,video/3gpp,video/quicktime]).SendKeys (filepath)
driver.Wait 2000 this wait time depends on the size of your file max 64 mb
driver.FindElementByXPath(//span[@data-icon = send]).Click
driver.Wait 1000
driver.FindElementByXPath(//div[@title = Menu]).Click
driver.FindElementByXPath(//div[@title=Log out]).Click
driver.Quit
End Sub Whatsapp Desktop Automation with VBA](https://i.ytimg.com/vi/kYcbEGYCABE/mqdefault.jpg)






