Hello, I am trying to get excel to play a sound when data is entered, we scan into a database and sometimes the data does not go through correctly and need some way to notify the user that the data has been entered into the cell so that they may continue scanning. However I am running into an issue where the formula will work in one cell but will not continue into the rest. I am trying to get cells A2 through A160 to play this sound but only A2 is working. The VBA I am using is :
#If Win64 Then
Private Declare PtrSafe Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As LongPtr, ByVal dwFlags As Long) As Boolean
#Else
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Boolean
#End If
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
Function SoundMe() As String
'Updateby Extendoffice 20161223
Call PlaySound("c:\windows\media\cash_register.wav", _
0, SND_ASYNC Or SND_FILENAME)
SoundMe = ""
End Function
which pulls the cash register wav file correctly and plays it when the formula in a162 is set to =IF(A2>0,SoundMe(),"") , however as soon as i set the formula to read =IF(A2:A160>0,SoundMe(),"") I'm greeted with a "#VALUE! error and then none of the cells are recognized to play the sound. I'm pretty sure my formula is not in the correct format to read cells a2 through a160 and was hoping that someone may have some insight on how i can get this to work. Any help is much appreciated!
#If Win64 Then
Private Declare PtrSafe Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As LongPtr, ByVal dwFlags As Long) As Boolean
#Else
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Boolean
#End If
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
Function SoundMe() As String
'Updateby Extendoffice 20161223
Call PlaySound("c:\windows\media\cash_register.wav", _
0, SND_ASYNC Or SND_FILENAME)
SoundMe = ""
End Function
which pulls the cash register wav file correctly and plays it when the formula in a162 is set to =IF(A2>0,SoundMe(),"") , however as soon as i set the formula to read =IF(A2:A160>0,SoundMe(),"") I'm greeted with a "#VALUE! error and then none of the cells are recognized to play the sound. I'm pretty sure my formula is not in the correct format to read cells a2 through a160 and was hoping that someone may have some insight on how i can get this to work. Any help is much appreciated!