VBA code to play wav sound file based on conditionl formatting

  • Hello,


    I would like to create an instance to play a wav sound effect for a couple of conditional formatting rules.


    1. I want to play a wav sound if a selected cell equals contains a specific value. ex: if C4 = Tacos then play wav sound effect


    2. I want to play a wav sound if a selected cell contains any value. ex: if C4 = any value then play wav sound effect.


    Thank you for any help.

  • That wouldn't be conditional formatting. If, when you write "selected," you mean someone clicks on the cell, then you will need to use the Worksheet's Selection Change event, e.g.,


    That's code on the worksheet object, not a standard module. If this is to run on 64-bit Excel, then you'd probably need directives around the lib call so it would use LongPtr.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!