View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson
 
Posts: n/a
Default add a sound if Cell R6 value greater than 120

You need to use a VBA Event procedure. Right-click the sheet tab
and choose View Code. In the code module that appears on the VBA
Editor, paste the following code:

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
sndPlaySound32 "chimes.wav", 0
End If
End Sub

Change the reference to A1 to the cell you want to test, and
change "chimes.wav" to the sound file you wish to play. If the
file is not one of the standard Windows sound files, you'll need
to include the complete folder name of the file.


Cordially,
Chip Pearson
Pearson Software Consulting, LLC
www.cpearson




"Moses" wrote in message
...
Hi, Does anyone know if I can add a .wav file if a cell value
is greater than
120? If so can you offer any advice?