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


I have a macro that I need to run when ever a calculation is performe
on the activesheet.

I am using the following code, in the workbook object to carry tha
out:

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)

With ActiveSheet

SheetNumberUpdate

End With

End Sub

It does fire when the calculation occurs and runs the macro, howeve
once it continues to run cycling back through the macro. Lather
rinse, repeat!

I tried placing the above code in the module with the macro but then i
doesnt work at all.

Help!!!!!!!!!

--
Hammer_75
-----------------------------------------------------------------------
Hammer_757's Profile: http://www.excelforum.com/member.php...nfo&userid=741
View this thread: http://www.excelforum.com/showthread.php?threadid=40046

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Workbook_SheetCalculate looping

You have a recursive loop. You should be able to fix it with

application.enableevents

AS with all application level settiing it should have an error handler to
deal with the potential of a crash

sub Whatever()
on error goto ErrorHandler
application.enableevents = false
'do your stuff

Errorhandler:
application.enableevents = true
end sub
--
HTH...

Jim Thomlinson


"Hammer_757" wrote:


I have a macro that I need to run when ever a calculation is performed
on the activesheet.

I am using the following code, in the workbook object to carry that
out:

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)

With ActiveSheet

SheetNumberUpdate

End With

End Sub

It does fire when the calculation occurs and runs the macro, however
once it continues to run cycling back through the macro. Lather,
rinse, repeat!

I tried placing the above code in the module with the macro but then it
doesnt work at all.

Help!!!!!!!!!!


--
Hammer_757
------------------------------------------------------------------------
Hammer_757's Profile: http://www.excelforum.com/member.php...fo&userid=7413
View this thread: http://www.excelforum.com/showthread...hreadid=400466


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Workbook_SheetCalculate looping


Thanks Jim, that works.

the education continue

--
Hammer_75
-----------------------------------------------------------------------
Hammer_757's Profile: http://www.excelforum.com/member.php...nfo&userid=741
View this thread: http://www.excelforum.com/showthread.php?threadid=40046

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
Looping Maggie[_6_] Excel Discussion (Misc queries) 6 October 2nd 08 09:14 PM
Looping David T Excel Discussion (Misc queries) 2 August 30th 06 10:51 PM
Next For looping in a If Jean-Jerome Doucet via OfficeKB.com Excel Programming 7 July 12th 05 07:46 PM
Looping scottwilsonx[_52_] Excel Programming 1 October 5th 04 04:13 PM
looping to End Nabeel Moeen Excel Programming 2 February 25th 04 10:52 AM


All times are GMT +1. The time now is 03:12 AM.

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

About Us

"It's about Microsoft Excel"