View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Karen53 Karen53 is offline
external usenet poster
 
Posts: 333
Default Why my procedure will re execute at a certain point in the procedu

Try this:

Private Sub Worksheet_Calculate()

Dim ShName As String
Dim Grid As String

On Error GoTo ws_exit
Application.EnableEvents = False

your code

ws_exit:
Application.EnableEvents = True

End Sub


--
HTH
Karen53


"lwchapman" wrote:

I have several routines (one in a module, the other in "sub
worksheet_calculate()."

In both, the code will execute until it reaches an undetermined line number,
then it will go back to the start of the procedure, run the commands and then
return to the next line from where it re executed. It will do this until it
has finally completed all the commands in the routine.

It may be that in the "sub worksheet_calculate()" procedure (in the
spreedsheet code page) that it writes to the worksheet which triggers a re
calculation and then returns to the beginning of the routine. If so, why
then would it return to the next line after the trigger command? In the
module routine this is not true. It is called from another routine in a User
Form. I have tried trapping it, work arounds, etc but nothing corrects this
problem. I am at a total loss!

Would anyone have any idea of what is occuring, or has had a similar problem
with a resolution?

Your advice, comments or suggestions would greatly be appreciated.

I use XP pro and Excel - Office 2007.

Regards - Larry