Looping through cells and adding sound

Help for Heroes

New member
Joined
Apr 7, 2013
Messages
1
Reaction score
0
Points
0
Hi, I'm trying to add a .wav sound to all cells in a column if it equals "! ALERT !", the sound will play when we manually data to some cells in a column. I have created a macro and added the following code:private Declare Function PlaySound Lib "winmm.dll" _ Alias "PlaySoundA" (ByVal lpszName As String, _ ByVal hModule As Long, ByVal dwFlags As Long) As Long Const SND_SYNC = &H0 Const SND_ASYNC = &H1 Const SND_FILENAME = &H20000 Sub PlayWAV() WAVFile = ThisWorkbook.Path & "\Windows Exclamation.wav" Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)End SubPrivate Sub Worksheet_Change(ByVal Target As Range) Threshold = "! ALERT !" If Range("AZ4").Value = Threshold Then PlayWAVEnd SubThis works for the first cell in the column and I'm assuming I'll need to add a loop within it to apply the same to the rest of the column cells. I would also like to reference .wav files in other files but using c:\BERT\BEAM-ME-UP-SCOTTY doesn't work? How do I do this and is it something to do with the FILEPATH? This is my first macro and I would appreciate help in achieving this, please help.Many thanksJ
 
Last edited:
Dare I suggest that instead of using sound (which may or may not be turned on, and which may or may not annoy the user as well as coworkers) you could instead simply use conditional formatting to make the cell fill red or yellow.
 
Back
Top