W7 64bit Excel 2010 nl

P

PeCoNe

Hallo,

I want to get a signal (play a wav file) if a specified cell is > or <
specified value.
How do i do that?

Bye Peter
 
C

Claus Busch

Hi Peter,

Am Mon, 13 May 2013 12:49:16 +0200 schrieb PeCoNe:
I want to get a signal (play a wav file) if a specified cell is > or <
specified value.

e.g. if A1 > 5 and A1 < 10:

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address <> "$A$1" Then Exit Sub
If Target > 5 And Target < 10 Then Beep

End Sub


Regards
Claus Busch
 
L

lhkittle

Hallo,



I want to get a signal (play a wav file) if a specified cell is > or <

specified value.

How do i do that?



Bye Peter

Hi Peter,

Give this a try, where you have values in C12:C20 and compare them to the values in E12:E20.

(I believe I had some help from Claus or GS on this code some months ago)

Regards,
Howard

Option Explicit
Option Compare Text
Private Declare Function sndPlaySound32 _
Lib "winmm.dll" _
Alias "sndPlaySoundA" ( _
ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
Sub CheckMyValues()
Dim c As Range
Range("C12").Select
For Each c In Range("C12:C20")
If c.Value = c.Offset(0, 2).Value Then
MsgBox "Answer " & c & " is equal.", vbOKOnly
c.Offset(1, 0).Select
Else
If c.Value > c.Offset(0, 2).Value Then
sndPlaySound32 "C:\Windows\Media\Chimes.wav", 0&
MsgBox "Answer " & c & " is greater than.", vbOKOnly
Else
sndPlaySound32 "C:\Windows\Media\woohoo.wav", 0&
MsgBox "Answer " & c & " is less than "
End If
End If
c.Offset(1, 0).Select
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top