Link to home
Start Free TrialLog in
Avatar of Narayanan Prabhu
Narayanan Prabhu

asked on

Hi, how to make a cell formula to only beep once in excel?

In excel, I have used vba's beep function to use that in cells. Now, the cell value changes incrementally (the cell value may incrementally increase or decrease).  The incremental value is +/- 100 only.  For eg., if the cell value is 1200 from the data feed, it positively increments either to 1300, 1400, 1500, etc., or negatively increments to 1100, 1000, etc.  I am only concerned about "A" particular cell in an excel sheet because the data feed happens only in ONE particular cell.

For every increment, I have used the VBA beep function to alert me.

Whenever the beep happens, I have to manually change the formula (=if(D5<>1500,beepnow,"") to the increment that just had happened. Else, it keeps on beeping.

What I require is, the formula should automatically beep once - that's all!  Then, the beep should happen only when there is incremental "change" in the cell D5. Otherwise, the beep shouldn't happen.  The data feed happens during most part of the day, but I wouldn't know when it would happen; hence this beep alert is a kind of helping me instead of sitting always in front of the system waiting.....

Can it be done with a formula or can it be done via VBA?  Kindly, help me on this.  Thank you! Prabhu
Sample.xlsm
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

I would use a static variable in your beepNow function:
Function Beepnow()
    Static triggered As Boolean

    If Not triggered Then
        Beep
        triggered = True    '// never gonna beep again, as long as the workbook isn't closed.
    End If
End Function

Open in new window

Avatar of Narayanan Prabhu
Narayanan Prabhu

ASKER

Hi Bill, It is great SOLUTION! Cheers! Thank you so much.!!!