+ Reply to Thread
Results 1 to 2 of 2

Macro to play sound when condition is met

  1. #1
    Registered User
    Join Date
    02-10-2006
    Posts
    1

    Macro to play sound when condition is met

    Hi there. I have a macro (as below) that plays sound when a cell value is >30. However, I would like to modiy this macro so that the sound does not play if the value changes from something >30 to another value >30. So ideally the macro would only make a sound if the value changes from something <30 to something >30.

    Eg. 29 => 31(play sound) => 32 => 33 => 29 => 35 (play sound).

    The cell value is continuously updating every second from Live market data (e.g. Reuters, Bloomberg). I would eventually like to be able to use the code to check numerous cells in my worksheet (e.g. A1:A1, L5:L5 and Y11:Y11) using the same criteria (i.e. >30).

    Many thanks!

    *******************************
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Me.Range("A1:A1")) Is Nothing Then
    With Target
    If .Value > 30 Then Call sndPlaySound32("C:\WINNT\Media\ringin.wav", 1)
    End With
    End If
    End Sub

    ******************

    Option Explicit

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

  2. #2
    Registered User
    Join Date
    02-09-2006
    Posts
    51
    Run your loop and if statements then put this in the right place.



    Application.Speech.Speak "type your text here"

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1