+ Reply to Thread
Results 1 to 7 of 7

Playing .WAV file based on cell value change

  1. #1
    Registered User
    Join Date
    01-07-2014
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    41

    Playing .WAV file based on cell value change

    Hi all,

    I am desperate for help with this after trawling every website I can think of.

    I have a spreadsheet with a database query attached (refreshing every 60 seconds) showing a stock summary by product.

    I need the spreadsheet to play a .WAV file when values change. i.e.;

    If cell A1 <6, play sound1.wav
    If cell A2 <6, play sound1.wav
    If cell A3 <6, play sound2.wav
    If cell A4 <6, play sound2.wav

    This may need to be repeated several times based on certain criteria. I have a total of about 30 cells which I need to be looked at individually (not a sum of) and to play the relevant sound.

    I have seen different people try to tackle this in different ways. The ideal way would be creating alarms in VBA and triggering them using a formula, but I cannot get these to work in Excel 2010 or 2013.

    Any help would be greatly appreciated!

    TM

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Playing .WAV file based on cell value change


    Hi,

    did you try with Worksheet_Change event ?

  3. #3
    Registered User
    Join Date
    01-07-2014
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    41

    Re: Playing .WAV file based on cell value change

    Hi Marc,

    When it comes to VBA, I am very much a novice!

    I have tried 2 different ways of doing this;

    Please Login or Register  to view this content.
    This seems to work for just cell A1, but I have no idea how to repeat it to play different sounds for different cells. I enter this code and if I enter the number 6 into A1, the sound plays. If I then go back to view code and then come back out of the code, this sound then seems to play if I enter <7 into ANY cell (very strange).

    The other way I have tried is this;

    Please Login or Register  to view this content.
    And then use formula =IF(A1<7,SoundMe(),"") to trigger it, but this just brings back #NAME?. I don't think this works on later versions of Excel.

    Can anyone see if I am making an obvious mistake?

    Many thanks,

    TM.
    Last edited by tangmere.milli; 08-07-2014 at 09:19 AM.

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Try this !


    According to forum rules, you must use code tags if you don't want to see your post locked !

    Your obvious mistake is not to respect TBTO rule : you check only A1 cell but not changed ones in Target ‼
    So it can't be very strange at all, it's only pure logic ! When logic fails, code can't work …

    Example to check any change in cell A1 to A5 :
    Please Login or Register  to view this content.
    Enjoy it and don't hesitate to click on bottom left Add Reputation !

    ___________________________________________________________________________________
    We are all very ignorant, what happens is that not all ignore the same things … (Albert Einstein)

  5. #5
    Registered User
    Join Date
    01-07-2014
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    41

    Re: Try this !

    Thanks for the tip Marc, I have now added code tags!

    Many thanks for your help with this as well, code works perfectly for what I need!

  6. #6
    Registered User
    Join Date
    01-07-2014
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    41

    Re: Playing .WAV file based on cell value change

    Hi Marc,

    I do have a slight issue with the spreadsheet now.

    If I type a quantity of <7 into cell A1 manually, the sound plays as expected.

    If the cell in A1 changes automatically based on a query data refresh (formula entered in this cell), then the sound does not play.

    Do I need to tweak this code slightly?

    Thanks again in advance!

    TM.

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Playing .WAV file based on cell value change


    If any event is launched, nothing to do …

+ 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] Print lines to a text file based on change in cell contents
    By cthreepo986 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-28-2013, 09:53 AM
  2. Playing an audio file from a macro.
    By AliJay in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2010, 03:22 AM
  3. External File(s) referenced and file links change based on row cell.
    By Jimmydageek in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-23-2009, 02:59 PM
  4. Playing a Sound Based on a Cell's Value
    By avengine in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-20-2008, 01:46 AM
  5. Playing a WAV file in Excel 2002
    By chalky in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-24-2006, 03:10 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