View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Check changes on a sheet

In your ontime event, save a copy of the sheet in an array. When the event
runs again, get a copy in an array again - then compare the arrays - repeat
until cooked.

here is some untested pseudo code that might give you some ideas

Public newTime as Double

Sub OnTimeEventMacro()
Static varrold as variant
newtime = now + timevalue("00:02")
if isempty(varrold) then
varrold = ActiveSheet.UsedRange.Value
Application.OnTime newTime,"OnTimeEventMacro"
exit sub
End if
varrnew = Activsheet.UsedRange
bChanged = False
for i = lbound(varrnew,1) to ubound(varrnew,1)
for j = lbound(varrnew,2) to ubound(varrnew,1)
if varrnew(i,j) < varrOld(i,j) then
bchanged = True
exit for
end if
Next
if bChange = True then
exit for
end if
Next
if bChanged = True then
' schedule new check
varrold = varnew
Application.OnTime newTime,"OnTimeEventMacro"
End If
End Sub


--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
Look at Chip Pearson's example of using Application.OnTime

http://www.cpearson.com/excel/ontime.htm


Regards,
Tom Ogilvy

"Lorenzo" wrote in message
m...
I hope somebody can help me out on this one, because I am seriously
stuck and quite desperate too.
I have a sheet full of formulas that update the sheet in real time
with info from bloomberg. Unfortunately, every now and then the
bloomberg service crashes and the screen stops updating, but nobody
realizes it. So the question is:
Is there a way of writing a macro that every 2 minutes will see if
there have been any changes (in the last 2 minutes) on the sheet, and
if there aren't any have an alert pop-up message appear? Possibly with
an alert sound too (default windows or whatever, I don't care)?
Thanks for any help you guys out there can give me.
Lorenzo