Hi everyone,
This is my first post. Please help me on this play sound problem
I am trying to compare cell values in column A with cell values in column B.
The idea is if B1 is <= C1 then play a sound file
and I want to do it all the way down to wherever I want since I'm trying to use this Macro to track Stocks I am watching and the list my grow or reduce anytime.
I found some great codes on graemeal's post about "Playing a sound on cell value" and try to modify it but have no luck to get it work.
Here's the original macro provided by VoG
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
Private Sub Worksheet_Calculate()
Const FName As String = "C:\Intel.wav"
Dim c As Range
For Each c In Range("F2:F6")
If c.Value >= 1 Then
Call PlaySound(FName, 0&, SND_ASYNC Or SND_FILENAME)
Exit Sub
End If
Next c
End Sub
Here's my mod which doesn't work (Modifications are in red)
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
Private Sub Worksheet_Calculate()
Const FName As String = "C:\Intel.wav"
Dim c As Range
Dim d As Range
For Each c In Range("B5:B16")
For Each d In Range("C5:C16")
If c.Value <= d.Value Then
Call PlaySound(FName, 0&, SND_ASYNC Or SND_FILENAME)
Exit Sub
End If
Next
Next
End Sub
Can someone plz tell me what i did wrong? I would really appreciate the help as I've been looking for the answer for the past month.
This is my first post. Please help me on this play sound problem
I am trying to compare cell values in column A with cell values in column B.
The idea is if B1 is <= C1 then play a sound file
and I want to do it all the way down to wherever I want since I'm trying to use this Macro to track Stocks I am watching and the list my grow or reduce anytime.
I found some great codes on graemeal's post about "Playing a sound on cell value" and try to modify it but have no luck to get it work.
Here's the original macro provided by VoG
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
Private Sub Worksheet_Calculate()
Const FName As String = "C:\Intel.wav"
Dim c As Range
For Each c In Range("F2:F6")
If c.Value >= 1 Then
Call PlaySound(FName, 0&, SND_ASYNC Or SND_FILENAME)
Exit Sub
End If
Next c
End Sub
Here's my mod which doesn't work (Modifications are in red)
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
Private Sub Worksheet_Calculate()
Const FName As String = "C:\Intel.wav"
Dim c As Range
Dim d As Range
For Each c In Range("B5:B16")
For Each d In Range("C5:C16")
If c.Value <= d.Value Then
Call PlaySound(FName, 0&, SND_ASYNC Or SND_FILENAME)
Exit Sub
End If
Next
Next
End Sub
Can someone plz tell me what i did wrong? I would really appreciate the help as I've been looking for the answer for the past month.
Last edited: