View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
jj jj is offline
external usenet poster
 
Posts: 2
Default Returning From VBA Event Code Called From Excel 4.0 Macro

I've developed a worksheet including some VBA code which is to be
added to dozens of workbooks, so that we can get the data in them into
a standardised format.

My worksheet includes some VBA code in the Worksheet_Calculate event,
and this has been causing conflicts when the workbook it's added to
already contains macros written in the Excel 4.0 XLM language.

If the XLM macro changes the workbook it triggers the
Worksheet_Calculate event, but this is then unable to hand control
back to the XLM macro which called it. The error message "No RETURN()
or HALT() function found on macro sheet" is displayed.

I've solved the problem by changing the old XLM macro so that the
first thing it does is to set workbook calculation to manual,
switching it back to automatic once it's made all its changes to the
workbook (A spot of error handling is needed here).

This works fine and everyone seems happy with the result, but is there
any way I can solve this problem by including some defensive VBA code
in the Worksheet_Calculate event itself?