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
Narayanan PrabhuAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewCommented:
Add this routine to the VBA for the specific Sheet you are monitoring,  Notice it specifies the cell to watch for a change, in your case D5.  Adjust the call to Beepnow if that isn't right, but that will execute anytime that cell (D5) changes.  No need for the other formula in a cell that you have.

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim TriggerCell As Range
    Set TriggerCell = Range("D5")
    If Not Application.Intersect(TriggerCell, Range(Target.Address)) Is Nothing Then
        Call Beepnow
    End If
End Sub

Open in new window



»bp
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fabrice LambertFabrice LambertCommented:
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

0
Narayanan PrabhuAuthor Commented:
Hi Bill, It is great SOLUTION! Cheers! Thank you so much.!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.