Large loop with subroutines and more loops inside ...
I have a question rgd. how to keep this orderly:
- I have a code containing two subroutines, which are called a number of times when parsing a list in Excel.
=> Could I put both sheets (I like to separate stuff, so there's one sheet for each of those subroutines) before the actual start of the processing?
=> That would help in keeping all the code halfway orderly because both subroutines are needed to clean the data from one worksheet and the Excel_file that is the root of all evil here has six worksheets - so I need to put the whole thing into one meta_loop with six iterations.
Any other suggestions for keeping it tidy and legible by non-techies are welcome as well.
Re: Large loop with subroutines and more loops inside ...
yes, of course - but the syntax is not my issue.
My concern is keeping it all halfway orderly and legible. I always split my script into one tab for every distinct workstep. So if I do a meta_loop around it all like this, the start and end of that loop will be a few tabs distant from one another.
Well, I guess that can't be helped then. I'll just insert comments in the script to make it clearer.
Re: Re: Large loop with subroutines and more loops inside ...
A good programming practice is to slim down your main loop to something short and understandable. If you can split the body of your main loop in different steps, and those steps are organized on different tabs, convert each tab into a SUB with a descriptive name, and your main loop (at the end) will become something like:
// Begin execution
CALL Initialize; // tab 2
FOR this and that
CALL SetupWorksheet; // tab 3
CALL Process; // tab 4
CALL Aggregate; // tab 5
CALL Finalize; // tab 6
CALL ExportAllResidentData; // tab 7
This structure allows you to provide explanations about the program logic in the right places
Another advantage is that in this way, you can hide the details of your SUBs in hidden sheets, while the main control - configuration - step logic remains visible and easy-to-change on the unhidden MAiN sheet.