+ Reply to Thread
Results 1 to 9 of 9

Beep sound when condition met.

Hybrid View

  1. #1
    Registered User
    Join Date
    02-08-2014
    Location
    Dublin
    MS-Off Ver
    Excel 2013
    Posts
    70

    Beep sound when condition met.

    Hi all,

    The macro below is adding the SUM cell. Is it possible to make a beep sound when SUM cell value will be the same as one on the left?


    If Target.Columns.count > 1 Then Exit Sub
    If Not Intersect(Target, Range("M3:M5000")) Is Nothing And _
    Target.count = 1 And IsNumeric(Target.Value) Then
        If Target.Value > 0 Then
        Application.EnableEvents = False
        count = WorksheetFunction. _
        RoundUp(Cells(Target.Row, "K") / Target.Value, 0)
        Target.Offset(1).Resize(count).EntireRow.Insert
        With Cells(Target.Row, "L")
        .Formula = "=SUM(" & .Offset(1, -1).Resize(count).Address(0, 0) & ")"
        End With
        Application.EnableEvents = True
        Cells(Target.Row, "N").Value = count
        s.Speak count
        End If
    End If

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Beep sound when condition met.

    Have you tried

    IF Cells(Target.Row, "L") = Cells(Target.Row, "K") Then Beep
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    02-08-2014
    Location
    Dublin
    MS-Off Ver
    Excel 2013
    Posts
    70

    Re: Beep sound when condition met.

    The problem is I have 10s of sum cells in column L and some of them already match. I need a beep only for the ones just matched the value.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Beep sound when condition met.

    Hi,

    I don't understand your concern. The code is only testing the single target cell. I'm assuming of course that your codes is in the Sheet Change event. You didn't show the procedure name.

  5. #5
    Registered User
    Join Date
    02-08-2014
    Location
    Dublin
    MS-Off Ver
    Excel 2013
    Posts
    70

    Re: Beep sound when condition met.

    Sample file for review as attached
    Attached Files Attached Files

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Beep sound when condition met.

    Hi,

    Put this as the first three lines in your procedure

     If Not Intersect(Target, Range("L:L")) Is Nothing Then
            If Cells(Target.Row, "L") = Cells(Target.Row, "K") Then Beep
     End If
    It will beep whenever you enter a value in column L that has the same value as column K on the same row.
    Last edited by Richard Buttrey; 02-26-2014 at 10:37 AM.

  7. #7
    Registered User
    Join Date
    02-08-2014
    Location
    Dublin
    MS-Off Ver
    Excel 2013
    Posts
    70

    Re: Beep sound when condition met.

    If I put the value manual then I have a beep.
    But when the SUM will get the value it self the its quiet.

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Beep sound when condition met.

    Hi,

    I hope we're not going round in circles.

    That's what the first code I gave you does. Put it immediately after the Application.EnableEVents = True

    When you subsequently said it didn't work I assumed you'd tried the original but wanted it to work when you manually enter the data.

  9. #9
    Registered User
    Join Date
    02-08-2014
    Location
    Dublin
    MS-Off Ver
    Excel 2013
    Posts
    70

    Re: Beep sound when condition met.

    I did it and no beep...


    Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim count
    Dim lngCounter As Long
    Dim cell As Range
    Dim s As Object
     Set s = CreateObject("SAPI.SpVoice")
    
    If Not Intersect(Target, Range("L:L")) Is Nothing Then
        If Cells(Target.Row, "L") = Cells(Target.Row, "K") Then Beep
    End If
    
    If Target.Columns.count > 1 Then Exit Sub
    If Not Intersect(Target, Range("M3:M5000")) Is Nothing And _
    Target.count = 1 And IsNumeric(Target.Value) Then
        If Target.Value > 0 Then
        Application.EnableEvents = False
        count = WorksheetFunction. _
        RoundUp(Cells(Target.Row, "K") / Target.Value, 0)
        Target.Offset(1).Resize(count).EntireRow.Insert
        With Cells(Target.Row, "L")
        .Formula = "=SUM(" & .Offset(1, -1).Resize(count).Address(0, 0) & ")"
        End With
        Application.EnableEvents = True
    Cells(Target.Row, "N").Value = count
     s.Speak count
     For i = 1 To 100
         i = i + 1
     Next i
     s.Speak "boxes for scanning!"
        End If
    End If
    
    If Not Intersect(Target, Range("A3:A5000")) Is Nothing Then
    Cells(Target.Row, Target.Column + 1).Activate
    End If
    If Not Intersect(Target, Range("H3:I5000")) Is Nothing Then
    Cells(Target.Row, Target.Column + 1).Activate
    End If
    If Not Intersect(Target, Range("I3:I5000")) Is Nothing Then
    Cells(Target.Row, Target.Column + 2).Activate
    End If
    If Not Intersect(Target, Range("K3:K5000")) Is Nothing Then
    Cells(Target.Row, Target.Column - 1).Activate
    End If
    If Not Intersect(Target, Range("B3:B5000")) Is Nothing Then
    Cells(Target.Row, Target.Column + 3).Activate
    End If
    If Not Intersect(Target, Range("E3:E5000")) Is Nothing Then
    Cells(Target.Row, Target.Column + 3).Activate
    End If
    
    If Target.Column = 8 And Target.count = 1 Then
        If Not IsNull(Target) Then
            If Target.Offset(, -4).Text Like "##:##" Then
            Target.Offset(, 5).Select
            End If
        End If
    End If
    If Not Intersect(Target, Range("J3:J5000")) Is Nothing Then
    Cells(Target.Row + 1, WorksheetFunction.Max(1, Target.Column - 2)).Activate
    End If
    If Not Intersect(Target, Range("M3:M5000")) Is Nothing Then
    Cells(Target.Row + 1, WorksheetFunction.Max(1, Target.Column - 5)).Activate
    End If
    If Not Intersect(Target, Range("K3:K5000")) Is Nothing Then
    Cells(Target.Row, WorksheetFunction.Max(3)) = Date
    Cells(Target.Row, WorksheetFunction.Max(4)) = Time
    End If
    If Not Intersect(Target, Range("F3:F5000")) Is Nothing Then
    Cells(Target.Row, WorksheetFunction.Max(7)) = Range("M1").Value
    End If
        Application.EnableEvents = False
    If Not Intersect(Target, Range("O3:O5000")) Is Nothing Then
        If IsEmpty(Target) Then
            Cells(Target.Row, 16).ClearContents
        ElseIf IsNumeric(Target) Then
            If Target.Value <> 0 And Cells(Target.Row, "N") > 0 Then
                Cells(Target.Row, 16) = "Total"
            ElseIf Target.Value < 0 Then
                Cells(Target.Row, 16) = "Short"
            Else
                Cells(Target.Row, 16) = "Overs"
            End If
        Else
            Cells(Target.Row, 16) = "Overs"
        End If
    End If
        Application.EnableEvents = True
    Exit Sub
    ErrHandler:
        s.Speak "Not!"
        For i = 1 To 100
        i = i + 1
        Next i
        s.Speak "on the list"
        MsgBox "Value not found"
        Range("B1").Activate
    
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Beep or Make Sound after Calcing
    By jimhome@starplace.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-23-2016, 02:32 PM
  2. Play sound when condition is met
    By Rufles in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-15-2014, 05:50 AM
  3. Auto "Beep" sound doesn't work
    By byron. in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-21-2012, 01:48 PM
  4. Beep Change The Sound
    By Bob in forum Excel General
    Replies: 0
    Last Post: 07-06-2006, 07:00 PM
  5. [SOLVED] can VBA be used to sound a *.wav file on condition(s)?
    By J_J in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-23-2005, 04:06 PM

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