+ Reply to Thread
Results 1 to 3 of 3

Checking if a cell contains an error, and then playing a sound - Cannot check if error

  1. #1
    Registered User
    Join Date
    06-09-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    92

    Question Checking if a cell contains an error, and then playing a sound - Cannot check if error

    Hello all, I currently have this code:
    PHP Code: 
    Option Explicit
     
    Private Declare Function sndPlaySound32 Lib "winmm.dll" _
    Alias 
    "sndPlaySoundA" (ByVal lpszSoundName _
    As StringByVal uFlags As Long) As Long
     
    Private Sub Worksheet_Change(ByVal Target As Range)
         
        
    Dim Cell            As Range
        Dim CheckRange      
    As Range
        Dim PlaySound       
    As Boolean
         
        Set CheckRange 
    Range("C:C")
        For 
    Each Cell In CheckRange
            
    If Cell.Value "#N/A" Then
                PlaySound 
    True
            End 
    If
        
    Next
        
    If PlaySound Then
            Call sndPlaySound32
    ("C:\windows\media\chord.wav"1)
        
    End If
         
    End Sub 
    I want it so that if a value in row C is an error ("#N/A") then it plays a sound to the user. I don't know how to adapt this code, any help would be appreciated, thanks.
    Regards,
    Usman.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Checking if a cell contains an error, and then playing a sound - Cannot check if error

    I think it's better
    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    06-09-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: Checking if a cell contains an error, and then playing a sound - Cannot check if error

    The user will not be looking at the screen during input, which is why I required a sound to be played. I tested your code but whether it is an error or not it still displays the message box, any ideas? Thanks

+ 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