ICAEW.com works better with JavaScript enabled.
Exclusive

Multiple Sparklines in a single cell

Author: Simon Hurst

Published: 06 Aug 2021

Exclusive content
Access to our exclusive resources is for specific groups of students, users, subscribers and members.

I was asked recently how to combine two different Sparkline charts in a single cell. This was one of those occasions when, although I came up with an answer that seemed to work, I couldn't help wondering whether there was an easier and better way.

If you know of one, please let us know at excel@icaew.com. The request was complicated by the need to create a column of Sparklines rather than an individual chart. If you haven't experimented with Sparklines, then one of the articles in John Tennent's Exploring Charts series provides a good introduction:

Simple methods such as trying to add two different Sparkline types to the same location failed: the second type of Sparkline just overwriting the first. Often, the solution to any requirement to overlay one part of a spreadsheet on another is the use of the Excel Camera and Linked Pictures. Once again, this feature has been covered in the past, most recently here:

A Linked Picture is a graphic object that displays the contents of a cell or range of cells elsewhere in a workbook. Linked Pictures are dynamic, so that when the source content changes, the Linked Picture also changes immediately. To overlay a picture of a range of cells over other cells, the Fill colour of the Linked Picture needs to be set to No Fill. In this example, we have used an Excel Table with two columns containing different types of Sparkline. Just to demonstrate compactly how this works, our Column Sparkline displays the first three months results and our Line Sparkline the results for the whole year. In practical use, if you had 12 columns of actual results and 12 columns of budget results, you could use the technique to display the comparison of actual results against budget for example.

We want to create a Linked Picture of the Line Sparkline in cells P2:P7 of our Table. We can do this by adding the Camera command to our Quick Access Toolbar, selecting the cells, and then clicking on the Camera command. We can then Paste the resulting Linked Picture wherever we want it. Using the Home Ribbon tab, Font group, Fill Color dropdown we can set the fill to No Fill to make the background of the picture transparent:

Excel screenshot
Although we can place our picture over the existing Column Sparkline cells, and it will be dynamic as far as changes to the existing data is concerned, it will not adjust to reflect the addition of new Table rows:
Excel screenshot

In order to allow for new rows, we need to change the data source for the Linked Picture from a fixed cell reference to a dynamic reference. We can create the dynamic reference using a Range Name for our Table column. Having undone our addition of the new Table row in order to return our Table to just 6 rows of data, we have created the Range Name "Spark2" to refer to cells P2:P7. The range referred to by the Range Name will change as rows are added to our Table.

With our Linked Picture selected, the data source will be shown in the Formula Bar and we can replace our cell reference with the reference to the Range Name:

Excel screenshot
Now, as we add rows to our Table, our Sparkline columns will automatically be copied down to the new rows and the use of the Range Name as the data source will ensure that our Linked Picture overlay will also expand automatically:
Excel community

Join the Excel Community

Do you use Excel in your organisation? Are you using it to its maximum potential? Develop your skills and minimise spreadsheet risk with our Excel resources. Membership is open to everyone - non ICAEW members are also welcome to join.

Excel polaroid