Hi guys,
I've been having problems with trying to set certain colours to certain graphs within an excel chart and then matching that colour to the font of a legend. The run-time error 1004 appears when there is no graph to select.
See the code below for reference. So for example, say I have built this sheet to automate for 5 graphs (capacity) within the one chart. Say I only have 3 actual graphs, therefore the error will occur on the line of code:
because there is no graph 4.
Now adding to the beginning of the code an error handler
deals with this problem, however while it skips the error in the above code, it does not skip the body of code next to it. In other words, because prior to the error, graph 3 was selected, it will continue with the 'workable' codes:
Thus working its way all the way to the last line of code. So in this particular example with 3 available graphs out of a capacity of 5, the colour index of the third (and last available) graph will be
and not
I hope I'm making sense. I would really appreciate it if anyone could come up with a solution or workaround please? Many many thanks in advance.
See below for the 'full code':
Bookmarks