View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Conan Kelly Conan Kelly is offline
external usenet poster
 
Posts: 419
Default add a sound if cell A180, A290, B1100, etc.....

Astroboy,

Q1) But I want to have Sound Alarm for Mutiple cells:

When
A1=80
A2=90
B2=80
R5=100
...etc..

Q2) And when from Cell B1 to B17 and if any cell value is = 100


I'm thinking the easiest way to do this might be to use a helper cell that
is hidden or out of the way. I'm gonna use cell C1 in this example, you can
choose which ever cell makes sense to you.

Use this formula in Cell C1:

=OR(A1=80,A2=90,B2=80,R5=100,...etc...,COUNTIF (B1:B17,"=100"))

Then in your code, you could do something like this:

If Range("C1") Then
sndPlaySound32 "chimes.wav", 0
End If


HTH,

Conan




"Astroboy" wrote in message
...
Hi Everyone,

Very Newbie here.. ;)

I was searching board and found bottom code and it works on ONE cell.

Q1) But I want to have Sound Alarm for Mutiple cells:

When
A1=80
A2=90
B2=80
R5=100
...etc..

Q2) And when from Cell B1 to B17 and if any cell value is = 100

Q3) How can I make sound to run about 10 seconds?

Thank you in advance....

Option Explicit
Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Private Sub Worksheet_Calculate()
If Me.Range("A1").Value 10 Then
sndPlaySound32 "chimes.wav", 0
End If
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
If Target.Value 10 Then
sndPlaySound32 "chimes.wav", 0
End If
End If
End Sub