maninjapan
06-17-2010, 10:49 AM
I'm trying to setup a sound alert for when a cell's value exceeds a certain value. Ive tried the following and it seems to work ok when I run it as a macro, but this doesnt help me much.
I would like it to just run constantly, as part of the spreadsheet, to alert me when a dynamically changing cell value (its a stock price) exceeds a certain value and will continue to run until the value goes back under the alert prcie or is stopped (planning to add a popup with a stop button later)
'========================================================================== ======
'- SIMPLE METHOD : PLAY A WAV FILE
'- Requires winmm.dll
'- Brian Baulsom October 2008
'========================================================================== ======
Private Declare Function mciExecute Lib "winmm.dll" _
(ByVal lpstrCommand As String) As Long
Dim WAVfile As String
'========================================================================== =======
'- CHECK CELL VALUE
'========================================================================== =======
Sub CheckCellValue()
If Range("A1").Value > 99 Then
PlayFile
End If
End Sub
'========================================================================== =======
'- PLAY THE FILE
'========================================================================== =======
Sub PlayFile()
WAVfile = "C:\Sounds\Sound.wav"
mciExecute ("play " & WAVfile)
End Sub
I would like it to just run constantly, as part of the spreadsheet, to alert me when a dynamically changing cell value (its a stock price) exceeds a certain value and will continue to run until the value goes back under the alert prcie or is stopped (planning to add a popup with a stop button later)
'========================================================================== ======
'- SIMPLE METHOD : PLAY A WAV FILE
'- Requires winmm.dll
'- Brian Baulsom October 2008
'========================================================================== ======
Private Declare Function mciExecute Lib "winmm.dll" _
(ByVal lpstrCommand As String) As Long
Dim WAVfile As String
'========================================================================== =======
'- CHECK CELL VALUE
'========================================================================== =======
Sub CheckCellValue()
If Range("A1").Value > 99 Then
PlayFile
End If
End Sub
'========================================================================== =======
'- PLAY THE FILE
'========================================================================== =======
Sub PlayFile()
WAVfile = "C:\Sounds\Sound.wav"
mciExecute ("play " & WAVfile)
End Sub