Split Data Range into Multiple Chart Series without VBA
by Jon Peltier
Peltier Technical Services, Inc., Copyright © 2008. All rights reserved.
In VBA to Split Data Range into Multiple Chart Series I shared a VBA procedure that split a range into separate series in a chart. In fact, this is fairly easy to do using conditional chart formatting techniques I describe on my web site (see Simple Conditional Charts). The way these techniques work is to use formulas in separate columns to capture values from the main data column when certain conditions are met.
The data used in the other post is shown below, with the conditional columns added.
| A | B | C | D | E | F | G | |
| 1 | City | X | Y | Atlanta | Boston | Chicago | Detroit |
| 2 | Atlanta | 4 | 15 | 15 | #N/A | #N/A | #N/A |
| 3 | Atlanta | 5 | 18 | 18 | #N/A | #N/A | #N/A |
| 4 | Boston | 6 | 16 | #N/A | 16 | #N/A | #N/A |
| 5 | Boston | 6 | 16 | #N/A | 16 | #N/A | #N/A |
| 6 | Boston | 7 | 12 | #N/A | 12 | #N/A | #N/A |
| 7 | Boston | 11 | 11 | #N/A | 11 | #N/A | #N/A |
| 8 | Chicago | 10 | 13 | #N/A | #N/A | 13 | #N/A |
| 9 | Chicago | 13 | 10 | #N/A | #N/A | 10 | #N/A |
| 10 | Chicago | 15 | 8 | #N/A | #N/A | 8 | #N/A |
| 11 | Detroit | 10 | 9 | #N/A | #N/A | #N/A | 9 |
| 12 | Detroit | 15 | 5 | #N/A | #N/A | #N/A | 5 |
| 13 | Detroit | 13 | 3 | #N/A | #N/A | #N/A | 3 |
| 14 | Detroit | 14 | 6 | #N/A | #N/A | #N/A | 6 |
The unique items from column A are entered into row 1 of columns D through G. The following formula is entered into cell D2 and filled into the entire range D2:G14:
=IF($A2=D$1,$C2,NA())
The formula compares the label in column A with the header in row 1: if they match, the formula returns the value in column C otherwise it returns #N/A, which is not charted in a line or XY chart (for a bar or column chart, use the empty string “” instead of NA()).
Select the X Values (B1:B14), then hold CTRL while you select the conditional Y values (D1:D14), then create a chart. After formatting, the result is identical to the chart processed by VBA approach:

Posted: Friday, May 23rd, 2008 under Charting Principles, Data Techniques.
Comments: 1
Comments
Comment from Frank R.
Time: Monday, August 18, 2008, 9:38 am
This is exactly what I was looking for. Thanks.






Write a comment