Excel VBA Sound Alert
This macro plays a .wav file (C:\Windows\Media\chord.wav) when a duplicate value is entered in Column A.
Also msgbox is opened and the msgbox shows repeated values’ row numbers.Used code to play the sound :
#If Win64 Then
‘Code is running in 64-bit Office
Private Declare PtrSafe Function sndPlaySound Lib “winmm.dll” Alias “sndPlaySoundA” ( _
ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
#Else
‘Code is running in 32-bit Office
Private Declare Function sndPlaySound32 Lib “winmm.dll” Alias “sndPlaySoundA” ( _
ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
#End If
….
#If Win64 Then
sndPlaySound “C:\Windows\Media\chord.wav”, 0&
#Else
sndPlaySound32 “C:\Windows\Media\chord.wav”, 0&
#End If