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
VBAMicrosoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
Narayanan Prabhu

8/22/2022 - Mon
Bill Prew

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Fabrice Lambert


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

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

Open in new window

Narayanan Prabhu

Hi Bill, It is great SOLUTION! Cheers! Thank you so much.!!!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck