Cell intercepts a value

mamos

New Member
Joined
Apr 26, 2011
Messages
5
How do I create an if function when a cell's value passes through or intercepts a value.

i.e. A live data input will change the cells value and I want the function to work when the value goes through value 4. i.e. cell values changes from 3.8 to 4.2.

Thanks
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Thanks for reply.

I only want the if function to occur once. i.e. the first time the cells value passes through value of 4 and not to occur everytime the cells value is above 4.
 
Upvote 0
It will take VBA to do that, what is it you want to do exactly when the value hits 4?
 
Upvote 0
I want it to play a sound.

Currently my code works as below and plays a sound when cell M6 is greater than 4 by using the function =alarm(M6,">=4"):

Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private m_lngReset As Long

Function Alarm(Cell, Condition)
Dim WAVFile As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
On Error GoTo ErrHandler
If Evaluate(Cell.Value & Condition) And m_lngReset < 1 Then
WAVFile = ThisWorkbook.Path & "\cashtill.wav"
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
Alarm = True
m_lngReset = m_lngReset + 1
Exit Function
End If
ErrHandler:
Alarm = False
End Function
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top