Hide line and legend on chart when data not present

Teckstein

New Member
Joined
Sep 24, 2012
Messages
11
I have a line graph that plots six lines from information in a data range. The data range is populated based upon which of 50 data sets the person wishes to view. This works great for data sets that have data for all six lines. However, some of the fifty sets have data for only two to five of the lines in the graph. When this is graphed, the line doesn't appear, but the legend for that line is still present. How can I adjust the chart to show only the lines and legend for instances when the data is present.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
The way I do this is to not use the legend. Instead, add one textbox linked to a worksheet cell for each line. Format this text box font to be the same color as the associated line.

Now, when there is no data to show, have the cell content become "" (a basic IF formula will suffice).

I have a line graph that plots six lines from information in a data range. The data range is populated based upon which of 50 data sets the person wishes to view. This works great for data sets that have data for all six lines. However, some of the fifty sets have data for only two to five of the lines in the graph. When this is graphed, the line doesn't appear, but the legend for that line is still present. How can I adjust the chart to show only the lines and legend for instances when the data is present.
 
Upvote 0
Thanks - a simple but elegant solution.

The way I do this is to not use the legend. Instead, add one textbox linked to a worksheet cell for each line. Format this text box font to be the same color as the associated line.

Now, when there is no data to show, have the cell content become "" (a basic IF formula will suffice).
 
Upvote 0

Forum statistics

Threads
1,215,097
Messages
6,123,076
Members
449,094
Latest member
mystic19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top