ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Sound For Calculated Number Exceeding Limit (https://www.excelbanter.com/excel-discussion-misc-queries/95415-sound-calculated-number-exceeding-limit.html)

Carl

Sound For Calculated Number Exceeding Limit
 
I created a macro to sound chimes when a number entered in column C exceeds
360. I need it to work when the number is the result of a calculation rather
than manual entry. Is this possible? Could anyone suggest changes to the
following code to accomplish this please? Thanks!

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Application.Run "chimes"
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 Then
On Error GoTo errors
If Target.Value 360 Then GoTo errors
End If
Exit Sub
errors:
On Error GoTo 0
Application.Run "chimes"
End Sub




Dave Peterson

Sound For Calculated Number Exceeding Limit
 
Maybe just use the worksheet_calculate event.

And if you mean any cell in column C, you could use something like:

Option Explicit
Private Sub Worksheet_Calculate()
Dim myRng As Range
Set myRng = Me.Range("C:C")

If Application.Max(myRng) 300 Then
Call Chimes
End If
End Sub

Application.Run isn't necessary in this situation.

Carl wrote:

I created a macro to sound chimes when a number entered in column C exceeds
360. I need it to work when the number is the result of a calculation rather
than manual entry. Is this possible? Could anyone suggest changes to the
following code to accomplish this please? Thanks!

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Application.Run "chimes"
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 Then
On Error GoTo errors
If Target.Value 360 Then GoTo errors
End If
Exit Sub
errors:
On Error GoTo 0
Application.Run "chimes"
End Sub


--

Dave Peterson


All times are GMT +1. The time now is 05:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com