View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Charles Chickering Charles Chickering is offline
external usenet poster
 
Posts: 272
Default If a cell contains a certfain value, Beep

Mike, in a normal module paste this code:
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000

Sub PlayWAV()
'Adapted from Jwalks code @: http://j-walk.com/ss/excel/tips/tip59.htm
Dim WAVFile As String
WAVFile = "C:\WINDOWS\Media\Windows XP Error.wav"
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub

Then in the code for the sheet you are working on paste this code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Code written 10_2_2006 By Charles Chickering
If Not Intersect(Target, Range("A1").Precedents) Is Nothing Then
If Range("A1") 90 Then
Call PlayWAV
MsgBox "A1 is greater than 90"
End If
End If
End Sub
--
Charles Chickering

"A good example is twice the value of good advice."


"Mike H." wrote:

I want to be alerted if a certain value would ever be the value of a cell.
For example, if I have a balance sheet and the total Assets do not equal the
total liabilities, I want to be notified. But I don't want to have to run a
vb macro to be alerted. I thought I could just get a notification when the
recalc is done that something is wrong. How do I set this up? I don't want
to add a Watch to a cell, because you get no visual or audio that there is a
problem. It just shows up in the watch box. I want to be beeped the instant
an out-of-balance condition is created. Thanks for any help you can give me.