Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Tom is offline
external usenet poster
 
Posts: 6
Default Workbook_SheetCalculate Events

Hi,

I am currently using Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
to execute code when the value of any cells (provided by external links)
change.

Is there any way to filter this so my code only runs if cells *within a
particular range* change? Something like :

if Sh.Range = within the range A1 to C10 then run the code
else do nothing

Seems a simple enough concept but I can't for the life of me figure it out!
I have to use "calculate" events rather than "change" events as the cells
are updated automatically, rather than by a user.

Thanks,

Tom


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Workbook_SheetCalculate Events

Tom,
Try this code in the worksheet module not the workbook module.
The code is only practical on a small range as the time required to
run it increases greatly as the range size increases.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


Option Explicit
Private varValue As Variant

Private Sub Worksheet_Calculate()
Dim lngR As Long
Dim lngC As Long

If Not IsEmpty(varValue) Then
For lngC = 1 To 3
For lngR = 1 To 10
If Me.Range("A1:C10")(lngR, lngC) < varValue(lngR, lngC) Then
'run your code instead of showing msgbox
MsgBox "ran code"
varValue = Me.Range("A1:C10").Value
Exit Sub
End If
Next 'lngR
Next 'lngC
Else
'run your code instead of showing msgbox
MsgBox "ran code_"
varValue = Me.Range("A1:C10").Value
End If
End Sub
'-------------


"Tom"
wrote in message
Hi,
I am currently using Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
to execute code when the value of any cells (provided by external links)
change.

Is there any way to filter this so my code only runs if cells *within a
particular range* change? Something like :

if Sh.Range = within the range A1 to C10 then run the code
else do nothing

Seems a simple enough concept but I can't for the life of me figure it out!
I have to use "calculate" events rather than "change" events as the cells
are updated automatically, rather than by a user.

Thanks,

Tom


  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Tom is offline
external usenet poster
 
Posts: 6
Default Workbook_SheetCalculate Events

Hmm looks interesting, thing is speed is absolutely of the essence for what
I'm doing. The whole code gets run several times a second and it needs to
be as responsive as possible. Which is why I'm trying to make it more
selective as to which cells trigger it to run, so it doesn't get run more
than absolutely necessary. The code also updates some cells, which in turn
could trigger it to be run again, or should application.enableevents=false
stop that?

Any other ideas most appreciated!


"Jim Cone" wrote in message
...
Tom,
Try this code in the worksheet module not the workbook module.
The code is only practical on a small range as the time required to
run it increases greatly as the range size increases.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


Option Explicit
Private varValue As Variant

Private Sub Worksheet_Calculate()
Dim lngR As Long
Dim lngC As Long

If Not IsEmpty(varValue) Then
For lngC = 1 To 3
For lngR = 1 To 10
If Me.Range("A1:C10")(lngR, lngC) < varValue(lngR, lngC) Then
'run your code instead of showing msgbox
MsgBox "ran code"
varValue = Me.Range("A1:C10").Value
Exit Sub
End If
Next 'lngR
Next 'lngC
Else
'run your code instead of showing msgbox
MsgBox "ran code_"
varValue = Me.Range("A1:C10").Value
End If
End Sub
'-------------


"Tom"
wrote in message
Hi,
I am currently using Private Sub Workbook_SheetCalculate(ByVal Sh As
Object)
to execute code when the value of any cells (provided by external links)
change.

Is there any way to filter this so my code only runs if cells *within a
particular range* change? Something like :

if Sh.Range = within the range A1 to C10 then run the code
else do nothing

Seems a simple enough concept but I can't for the life of me figure it
out!
I have to use "calculate" events rather than "change" events as the cells
are updated automatically, rather than by a user.

Thanks,

Tom




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Workbook_SheetCalculate Events

Did you try the code?
Jim Cone
San Francisco, USA
http://www.officeletter.com/blink/specialsort.html


"Tom"
wrote in message
Hmm looks interesting, thing is speed is absolutely of the essence for what
I'm doing. The whole code gets run several times a second and it needs to
be as responsive as possible. Which is why I'm trying to make it more
selective as to which cells trigger it to run, so it doesn't get run more
than absolutely necessary. The code also updates some cells, which in turn
could trigger it to be run again, or should application.enableevents=false
stop that?

Any other ideas most appreciated!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
do events? background events cereldine[_15_] Excel Programming 1 April 12th 06 01:06 PM
events? [email protected] Excel Discussion (Misc queries) 1 September 14th 05 03:26 PM
Workbook_SheetCalculate looping Hammer_757[_11_] Excel Programming 2 August 30th 05 08:39 PM
Events ojv[_2_] Excel Programming 3 October 22nd 04 01:59 PM
events jacob Excel Programming 2 September 7th 04 02:15 PM


All times are GMT +1. The time now is 11:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"