I am using the "Function," below, which appears to be different than a "Sub"
Routine type Macro, because in a sub-routine I can call another sub-routine
and in this thing, I can't.
Actually, all I want this thing to do is to play a sound (which it does just
fine) and then change the value of a particular cell from 0 to 1.
Boy - Programming in VBA is a real pain for me. I can't get it to do what I
would consider simple things. I guess there is probably a steep learning
curve and then it gets easier.
Thanks very much for responding!!!
'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 & "\sound.wav" 'Edit this statement
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
Alarm = True
Exit Function
End If
ErrHandler:
Alarm = False
End Function