+ Reply to Thread
Results 1 to 22 of 22

Ding sound for Cells with Equal Values

Hybrid View

geepeeone Ding sound for Cells with... 02-21-2009, 05:26 AM
DonkeyOte Re: Edit My VBA Please 02-21-2009, 05:27 AM
geepeeone Re: Edit My VBA Please 02-21-2009, 05:35 AM
VBA Noob Re: Edit My VBA Please 02-21-2009, 05:36 AM
geepeeone Re: Edit My VBA Please 02-21-2009, 05:42 AM
DonkeyOte Re: Ding sound for Cells with... 02-21-2009, 05:59 AM
  1. #1
    Registered User
    Join Date
    02-20-2009
    Location
    San Francisco, CA
    MS-Off Ver
    Excel 2003
    Posts
    32

    Ding sound for Cells with Equal Values

    'Hi,

    'I was wondering how to apply this code to include specifically these ranges in pairs: H50 & H51, H102 & H103, H154 & H155, and H206 & H207.

    'tried to cut and paste the code from Private Sub to End Sub changing only
    the Ranges (see above), but it didn't work.

    'I am totally new to VBA

    Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
        "sndPlaySoundA" (ByVal lpszSoundName As String, _
        ByVal uFlags As Long) As Long
     
    Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
        Static OnlyOnce As Boolean
     
        If OnlyOnce Then Exit Sub
        If Range("H51").Value = "" Or Range("H51").Value = 0 Then Exit Sub
        If Range("H50").Value = Range("H51") Then
            sndPlaySound32 "ding", 1&
            OnlyOnce = True
        End If
     
    End Sub
    Last edited by VBA Noob; 02-21-2009 at 06:03 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Edit My VBA Please

    [deleted - non-Mod acting as a Mod - bad...]

  3. #3
    Registered User
    Join Date
    02-20-2009
    Location
    San Francisco, CA
    MS-Off Ver
    Excel 2003
    Posts
    32

    Re: Edit My VBA Please

    Quote Originally Posted by DonkeyOte View Post
    [deleted - non-Mod acting as a Mod - bad...]
    I don't understand. Do you have any suggestions going about this?
    Basically, I just want to do a "ding" sound to notify the user that the named pairs are equal. I thought it would be easy.

    I am already using the beep for other purposes i.e., pair of cells with different values.

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: Edit My VBA Please

    geepeeone,

    Welcome to the forum. You need to read the forum rules below and then edit your post to include code tags plus amend you're title

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    Many thanks

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  5. #5
    Registered User
    Join Date
    02-20-2009
    Location
    San Francisco, CA
    MS-Off Ver
    Excel 2003
    Posts
    32

    Re: Edit My VBA Please

    Thank you for the Welcome VBA Noob.

    Quote Originally Posted by VBA Noob View Post
    geepeeone,

    Welcome to the forum. You need to read the forum rules below and then edit your post to include code tags plus amend you're title

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    Many thanks

    VBA Noob

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Ding sound for Cells with Equal Values

    Untested but perhaps:

    Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
        "sndPlaySoundA" (ByVal lpszSoundName As String, _
        ByVal uFlags As Long) As Long
    
    Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
    Dim lngRow As Long
    Static onlyonce As Boolean
    If onlyonce Then Exit Sub
    Rem Pairs: H50 & H51, H102 & H103, H154 & H155, and H206 & H207
    For lngRow = 50 To 206 Step 52
        If onlyonce Then Exit Sub
        If Cells(lngRow, "H") <> "" And Cells(lngRow, "H") <> 0 Then
            If Cells(lngRow, "H") = Cells(lngRow + 1, "H") Then
                sndPlaySound32 "ding", 1&
                onlyonce = True
            End If
        End If
    Next lngRow
    End Sub
    Last edited by DonkeyOte; 02-21-2009 at 06:03 AM. Reason: removed unnecessary variable...

  7. #7
    Registered User
    Join Date
    02-20-2009
    Location
    San Francisco, CA
    MS-Off Ver
    Excel 2003
    Posts
    32

    Re: Ding sound for Cells with Equal Values

    Hi DonkeyOte,

    Thank you for taking the time.

    I went ahead and pasted the code.
    H50 & H51 worked, but not for the other pairs of cells



    Quote Originally Posted by DonkeyOte View Post
    Untested but perhaps:

    Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
        "sndPlaySoundA" (ByVal lpszSoundName As String, _
        ByVal uFlags As Long) As Long
    
    Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
    Dim lngRow As Long
    Static onlyonce As Boolean
    If onlyonce Then Exit Sub
    Rem Pairs: H50 & H51, H102 & H103, H154 & H155, and H206 & H207
    For lngRow = 50 To 206 Step 52
        If onlyonce Then Exit Sub
        If Cells(lngRow, "H") <> "" And Cells(lngRow, "H") <> 0 Then
            If Cells(lngRow, "H") = Cells(lngRow + 1, "H") Then
                sndPlaySound32 "ding", 1&
                onlyonce = True
            End If
        End If
    Next lngRow
    End Sub

+ 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