Example follows:-
In a standard code module enter the following:
Const WFile As String = "C:\WINNT\Media\Ringin.Wav"
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
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 As Range, Condition As String) As String
If Not IsNumeric(Cell.Value) Then
Alarm = "Enter a number you idiot !!!"
ElseIf Evaluate(Cell.Value & Condition) Then
Call PlaySound(WFile, 0&, SND_ASYNC Or SND_FILENAME)
Alarm = "Answer the phone !!!"
ElseIf Not Evaluate(Cell.Value & Condition) Then
Alarm = "Get back to work !!!"
End If
End Function
You will likely have to replace the path shown above to the wave file of
your choice. The following line likely needs to be corrected:
Const WFile As String = "C:\WINNT\Media\Ringin.Wav"
In cell B1 enter the formula:
=Alarm(A1, "=100")
Now in cell A1 enter miscellaneous values (numbers or text). The sound
should fire only when you enter the number 100. You can change the criterion
to whatever you like. Enter it in quotes. If you want the sound to fire when
the number is greater than or equal to 10 then enter ">=10".
Regards,
Greg