Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88809

Cannot Run Visual Basic Editor Because of a Syntax error after splitting workbook into two

$
0
0

I have a VBA Excel model which I have separated into two separate workbooks: InputsWB, which contains all the inputs for the model, and RunnerWB, which contains the bulk of the VBA code (and all the class modules live here). Depending on the needs of the user, the InputsWB can either call the macro in the RunnerWB or the RunnerWB can call multiple versions of the InputsWB. The detail doesn't matter for this question but the two workbooks need to be separated.

Mysteriously, after the split I sometimes get a Run-time 1004 error with the message Cannot Run Visual Basic Editor Because of a Syntax error. If I Debug + F5 then the code runs until it encounters the next Application.Calculate.

I have seen many similar questions while recording macros, or on Application.Calculate. I think mine is related to the Application.Calculate, but those answers don't explain why this happens. Some reasons I can think off, but cannot confirm online is:

  1. There are Modules in the two workbooks with the same names (although I've changed the modules names in the InputsWB but still get the error on occasion.
  2. There are VBA functions in the two workbooks with the same names

Are there any other reasons why I could be getting these errors?

UPDATE:

I finally realised why I got this error. I am calling a macro in my RunnerWB from my InputsWB. However, there was a duplicate function declared in my RunnerWB. Usually, this would give a Compile error: ambigious name detected when the macro was initiated from ThisWorkbook. However, because it was initiated from another workbook I got the Syntax error explained above.


Viewing all articles
Browse latest Browse all 88809

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>