If you have ever tried to record a macro only to later discover that you’re getting ‘macro too long’ error message, you should consider to split a big macro project more that 1,400 lines) into several parts. Once you record separate macros (or, alternatively, you can record the whole thing and later cut it manually in code into several macros – requires more than just a very basic skills and so not recommended for novices) you need to make a new macro which will ‘call’ part A, B, C etc. one after another to execute the full project.
In below example you can see visual basic command ‘call’ + [macro name] repeating several times – this runs each macro within the bigger picture. I have also used ‘If’ condition – you can set the criteria in the master macro file (xlsm – macro enable spreadsheet) and then using the drop down menu use your own way to customise your report.
See the example code below.
Sub Big Project()' ' Big Project Macro '' If Range("l16").Value = "Yes" Then Call Project_Presorting End IfIf Range("l12").Value = "Yes" Then Call Project_PartA Call Project _PartB End IfIf Range("l12").Value = "No" Then (this condition excludes option of running macro called Project_PartB) Call Project_PartA End If If Range("l18").Value = "Yes" Then Call Project_Part C End IfEnd Sub