I'm updating a macro and need help with the control flow. I'm not a programmer by trade, so control flow isn't something I've encountered before.
The current version of the macro works as follows:
The current version only works if both A & B are present, but I need it to work if only either A or B is present. At first I figured I could copy/paste the relevant sections and just skip to them using GoTo statements, but it seems that's bad practice.
How do I navigate the code handling 4 possible scenarios? (A+B, neither, only A, only B). For context, I call a separate sub to create & format the 2nd & 3rd workbooks.
I've considered these options, but unsure which is more appropriate:
I'm looking for whichever method is cleanest, easiest to maintain, and quicker to run (if the differences aren't negligible). I'm leaning towards separate subs, but wanted to check here first.
If I were you I would create a variable "scenario", and I woudl assign it a value depending on the case you are in. Ex : If scenario = 1 then Call (your procedure for case A+B for instance)
Elseif Scenario = 2 then Call (your procedure for case A only etc..). I really recomand to avoid the GoTo procedures which are not that much effective in my opinion.