locked
play different tone for cell based on different values RRS feed

  • Question

  • I have a column of excel data that ranges from 0 to 400 and I want to "hear" that data.  I'm thinking of code that would start at the top of the column in cell A2, play a tone for that value and then move to the next cell....play a tone for whatever that value is, etc.  When it hits a blank cell, it terminates.

    The number of unique values in the column might be 80 or rmore. 

    I could have about 600 lines of data collected over about 2 seconds.  I want to play it back in the same timeframe.   So the time the code takes would be about 2 sec.

    I am not a vb-savy person but I'm learning....so any directions and help should be idiot proof :-)

    Regards !

    PS-->    Is it possible to take the cell value and play a wav tone back at a different pitch based on simple math like [CellValue / ValueRange] ?  So if the ValueRange is 0 to 400 (i.e. 400) and my CellValue is 80, the factor would be 80/400 = 0.20.   Could that be used as a frequency value of some kind ??

    Thursday, January 10, 2013 7:26 PM

All replies

  • Excel is not for making music, but off course you can play sound using API. 

    You can record more sound because you cand module sound value and use it  depending on thevalue of a cell. This is a example how to play it.

    Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    Private Const SND_FILENAME = &H20000
    
    Sub graj(co$)
      Const kat$ = "C:\Windows\Media\"
      sndPlaySound kat & co, SND_FILENAME
    End Sub
    
    Private Sub MusicPlay()
    Dim x&
    For x = 1 To 30
    DoEvents
        Select Case Cells(x, "a")
            Case 1 To 10:  Call graj("tada.wav")
            Case 11 To 20: Call graj("Windows Battery Low.wav")
            Case 21 To 30: Call graj("Windows Critical Stop.wav")
        End Select
    Next x
    End Sub

    You can try like this one. Set A1 to A30 different values. 


    Oskar Shon, Office System MVP

    Press if Helpful; Answer when a problem solved

    Friday, February 1, 2013 10:30 PM
    Answerer