I'm trying to set up VBA and logical test so that if A1 is greater than B6, a sound clip will play, alerting me even from my sleep.
Here are the codes.
VBA:
Logical question in the cell:
Now, the problem is that the sound plays regardless of the logic function. It plays whether A1 is greater or less than B6.
Any help would be much appreciated. Also, I could need some help on how to stop the sound once it starts playing.
Here are the codes.
VBA:
Private Declare PtrSafe Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As LongPtr, ByVal dwFlags As Long) As Boolean
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
Function SoundMe() As String
Call PlaySound("c:\soviet.wav", _
0, SND_ASYNC Or SND_FILENAME)
SoundMe = ""
End Function
Logical question in the cell:
=IF(A1>B6, SoundMe(),"")
Now, the problem is that the sound plays regardless of the logic function. It plays whether A1 is greater or less than B6.
Any help would be much appreciated. Also, I could need some help on how to stop the sound once it starts playing.