One-click variable width column charts in Excel

The Poorhouse spends increasing amounts of his time with his head buried in the pile of small grey rectanges that is Microsoft Excel. This mind-boggling time is sometimes more than it really needs to be due to strangely lacking features in this program of a billion obscure functions. Take for example the variable width column chart (aka as the a start towards a matrix or Marimekko chart).

One use of such a beast is to represent 2 dimensions of data within a simple bar format - the height of the bars is the classic key dimension, and the width is another. Below is an example of this in practice. This made-up chart shows the amount of income generated by sales of cars by the paint colour of the car on the Y-axis, and the quantity of cars sold itself is reflected in the width of the bar. The wider the bar, the more cars were sold. Blue cars clearly generated the most income - and the wide width of the bar shows that this could be because the largest proportion of cars sold were blue (in the real world of course the chart would be appropriately captioned...). [edit: this isn't a great example from the point of view of chart clarity, see the comments for why - but the principle of how to make the chart stands!]

Now, this isn't a built-in Excel chart type sadly and it's a faff to do, so below is a macro to 1-click do it for you.

Yes, it's a bit of a workaround, but based on a cunning enough technique - 100% as documented in an article from Excel charting wizard Jon Peltier as documented at Techtrax. Be sure to read it for the real lowdown, and much gratitude to him for writing it. Basically, triplicate your data into a new arrangement, plot it as an area chart with a time-scale axis = success.

Faffing around with the data when you're doing more than a couple of these charts is a pain. Especially if, like the Poorhouse, you wanted a clustered columns effect like the below - a fictional graph along the same lines as the above example, but this time the income and sales quantities are compared between two quarters.

So here's a macro that does it all for you in one click. Download it in a workbook here, or alternatively also available as a text file here for easy pasting into your own workbooks.

Instructions to use: ensure your original data is in an arrangement approximating the below generic format. You can add on as many columns to the right if you have several column clusters to chart, and of course use as many rows downwards as you need for your data (edit: subject to the limits of Excel - 65,536 rows and 256 columns in v2003, more in more modern versions). It's a common arrangement for standard column charts, but of course here one column indicates the width of the bars. In the top left cell, enter a number to represent the space you want the chart to have between each cluster of columns (including the first one - i.e. spacing from the Y-axis).

Then select all the data including the headings and space value, and run the macro - called "VariableWidthColumnChart" unless you change it.

A new sheet will automatically be inserted into your workbook, you data rearranged as is necessary for the stacked area chart technique described by Jon to work, and the chart drawn. Happy days.

No guarantees etc...but it works for the Poorhouse, or at least well enough that the corporate overlords don't complain. Written for Excel 2003 on Windows, will likely work elsewhere too.


AttachmentSize
Variable width column chart macro in an Excel workbook25.5 KB
Variable width column chart macro as text5.27 KB

Comments

Thanks plus remark

Thanks a lot! I have been struggling with finding a solution to the same problem for a long time. I have one remark and a suggestion, though. I have found that the limit of rows is 256, so it would be nice to add "up to 255" after the instruction "You can add on as many columns to the right if you have several column clusters to chart, and of course use as many rows downwards as you need for your data".

Glad it helped, and thanks

Glad it helped, and thanks for the suggestion, I added it in.

The newer versions of Excel can do more columns apparently (16,384) but you're right, it's still a finite number!

Be careful

Interesting technique but (and I realise it's only an example) the first chart isn't good - the number of cars sold is already implicit in the revenue, really you'd want the width to equal cars sold, the height to equal price per car and therefore the area = revenue from those cars. Otherwise its exaggerating the differences.

Point taken! Indeed with

Point taken! Indeed with variables that are so dependent on each other, it does exaggerate the difference a lot, your way is much better. As you say, it was a example to illustrate a point, but I'll note in the article above tha tit's not a good one, thanks.

X-Axis as Time-Scale not working

So the macro works great! However, when I try to change the x-axis to time scale (right click on axis > format axis > date axis), the axis does not change to the variable width. Help!