Home |
Search |
Today's Posts |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Tom,
That did it ! Reading the whole watched range into a variable and then checking for any change to activate the alarm sound was magnificent. You are not judt teaching me "how" to code but how to "think for alternatives" as well. Your Worksheet_Change sub is superb. Thanks a million... J_J "Tom Ogilvy" wrote in message ... In your general module add the declaration at the top outside any procedu '------------------ Public vArr as Variant Sub zaman() Sheets("Sheet1").Range("A1").Value = Hour(Now()) Sheets("Sheet1").Range("B1").Value = Minute(Now()) Sheets("Sheet1").Range("C1").Value = Second(Now()) Nextzaman End Sub '------------------------------- Private Sub Nextzaman() Application.OnTime Now + TimeValue("00:01:00"), "zaman" End Sub '-------------------------- 'In Sheet1 code page I have your code (alter as shown) Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range, rng as Range Dim i as Long, j as Long Dim bChange as Boolean On Error Resume Next if Target.Address = "$C$1" Then bChange = False For Each c In Range("D2:G5") i = c.row - 1 j = c.column - 3 if c.Value < vArr(i,j) then bChange = True exit for end if Next c if bChange then Interaction.Beep vArr = me.Range("D2:G5").Value End if End if On Error GoTo 0 End Sub 'and in ThisWorkbook code page I have: '-------------------- Private Sub Workbook_Open() Application.Run "zaman" vArr = Sheets("Sheet1").Range("D2:G5" End Sub '---------------------------------------- Private Sub Workbook_BeforeClose(Cancel As Boolean) ThisWorkbook.Save End Sub '---------------------------- -- Regards, Tom Ogilvy "J_J" wrote in message ... Hi Tom, Yours and Bernie Deitrick's proposals achieved a solution of stopping "false alarms" (beeps that occur because of the system clock minute changes reflected by another macro). But now although there is no sound beeps on minute changes, there is no sound either on changes with the watched range display. Possibly I am missing something...or we all are.:) Regards J_J "Tom Ogilvy" wrote in message ... Maybe: Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range, rng as Range On Error Resume Next set rng = Range("A1:B1") ' don't trigger on a change to A1 or B1 if not intersect(rng,Target) is nothing then exit sub For Each c In Range("D2:G5") If Not Application.Intersect(Target, c.Precedents) Is Nothing Then Interaction.Beep End If Next c On Error GoTo 0 End Sub -- Regards, Tom Ogilvy "J_J" wrote in message ... The below code '------------------------- Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range On Error Resume Next For Each c In Range("D2:G5") If Not Application.Intersect(Target, c.Precedents) Is Nothing Then Interaction.Beep End If Next c On Error GoTo 0 End Sub '---------------------- sound on each minute change of my system clock. You see, cells A1 and B1 displays the system clock hour and minute values. And the watching cells (Range D2:G5) look to the values displayed in A1 and B1. Then the main macro is executed in minute intervals to let A1 and B1 refresh their displays. Now although no "display" change is valid in the watched cells the sound alarm beeps in minute intervals too. Maybe my other suggestion may prevent that. I hope I didn't confuse you... Hope we can solve this problem. Regards J_J |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sounds | Excel Discussion (Misc queries) | |||
sounds in Excel | Excel Discussion (Misc queries) | |||
Excel Sounds | Excel Discussion (Misc queries) | |||
convert time from 60 minute hour to 100 minute hour | Excel Discussion (Misc queries) | |||
convert 100 minute hour to a 60 minute hour | Excel Worksheet Functions |