I am trying to configure an alarm based on the value of a cell which is linked to a web query
The formula is:
=Alarm(D7;">=1")
The VBA code is:
'Windows API function declaration
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long
Function Alarm(Cell, Condition)
Dim WAVFile As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
On Error GoTo ErrHandler
If Evaluate(Cell.Value & Condition) Then
WAVFile = ThisWorkbook.Path & "\ferrari250.wav"
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
Alarm = True
Exit Function
End If
ErrHandler:
Alarm = False
End Function
Why does the Alarm formula return True in cels E3 when the condition is referenced to D3 while the same Alarm function returns False in cels E5,6,7 & 9 when the condition is referenced to D5,6,7 & 9 (where the value clearly exceeds 1).
I would like the Alarm function to work with cel reference D7.
I really appreciate your comments and hope you can point me in the right direction.
The formula is:
=Alarm(D7;">=1")
The VBA code is:
'Windows API function declaration
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long
Function Alarm(Cell, Condition)
Dim WAVFile As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
On Error GoTo ErrHandler
If Evaluate(Cell.Value & Condition) Then
WAVFile = ThisWorkbook.Path & "\ferrari250.wav"
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
Alarm = True
Exit Function
End If
ErrHandler:
Alarm = False
End Function
Why does the Alarm formula return True in cels E3 when the condition is referenced to D3 while the same Alarm function returns False in cels E5,6,7 & 9 when the condition is referenced to D5,6,7 & 9 (where the value clearly exceeds 1).
I would like the Alarm function to work with cel reference D7.
I really appreciate your comments and hope you can point me in the right direction.