Lesson 39: 2 datasets of 10 data points each draw 2 graphs in 2 charts

Previously, you have learned how to draw 2 graphs in 1 single chart.

How about 2 graphs in 2 separate charts but in 1 worksheet?

Something like this:

Let us show you how.

First create the necessary data as shown above using Revenue and Costs as the example.

You will need 5 subroutines:

  1. DrawAllCharts
  2. RemoveAllCharts
  3. DrawRevenueChart
  4. DrawCostsChart
  5. ArrangeMyCharts
DrawAllCharts is the main subroutine which you will run.
As you can see, DrawAllCharts will call the other 4 subroutines.
RemoveAllCharts will remove all the charts to prevent the file from becoming bigger. We do not want to add charts without any limit. This is similar to what we have done in the past 2 lessons, except we now isolate this code in a single subroutine.
DrawRevenueChart and DrawCostsChart are largely the same except for where to retrieve the data, the title and the line color in the graph.
Finally we have ArrangeMyCharts. You can synchronize the height and width of all the charts in the same worksheet.
You can even set as to where the charts will be populated from.
You can even set it such that you can have columns of charts, rather than 1 single long column of charts.
In this example, I chose just 1 column of charts.
<< Previous | Next >>