I am trying to have any cell that in any row in any column (based upon code address change) that would Speak a word if the number is Under <10 and play a sound (wav) if the number is over >10.
This code works fine for all of column A, but on column B it uses the Speech and Sound from column C.
Thank you for your help.
This code works fine for all of column A, but on column B it uses the Speech and Sound from column C.
Thank you for your help.
Code:
Private Declare Function sndPlaySound Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim strSound As String
Dim strtalk As String
If Not Intersect(Target, Range("$A$1,$A$2,$A$3,$A$4,$A$5,$A$6,$B$2,$C$2")) Is Nothing Then
If Target.Column = 2 Or Target.Column = 3 Then
strSound = Choose(Target.Row, "Drumroll", "beep")
strtalk = Choose(Target.Row, "house and horn", "Dog and cat")
Else
strSound = Choose(Target.Row, "tada", "ding", "tada", "beep", "ding", "beep")
strtalk = Choose(Target.Row, "Dog", "Cat", "Pig", "House", "cat", "Rat")
End If
If Target.Value > 10 Then
sndPlaySound "C:\WINDOWS\Media\" & strSound, 0
End If
If Target.Value < 10 Then
Application.Speech.Speak strtalk, 0
End If
End If
End Sub
Comment