1
votes

I've spent the whole night doing fruitless "NG" retakes of a long series of Excel VBA scripts, only to encounter repeated issues of Compile Error "Procedure too Large".

As such, I would like to share my story and solution, and would also love to hear from you if you have any better ideas.

1

1 Answers

1
votes

I debugged in Visual Basic, and found that by removing the following lines, the problem was resolved:

ActiveWindow.ScrollRow = 10
...
ActiveWindow.ScrollRow = 10000

I realised that as my records had more than 10k rows, Macro also captures each of my mousescrolls or keyboard page-down scrolls as an additional macro command all by itself. As such, it choked up the memory limits for the macro due to multiple downward scrolls. So, the problem was resolved by simply deleting all the lines associated with "ActiveWindow.ScrollRow".

I guess it would have helped if I had used a newer MS version or a more powerful Mac. Suggestions are welcome on how the Macro recording could have been better done, especially on the need to scroll down to capture deep rows. Do note that I did not select the entire column (by clicking on the column headers) to avoid hitting the max limit of the rows (hence adding unnecessary CPU load ... I guess). What about folks using newer Office like 2013 ... was it worth the upgrade as far as Macros are concerned?