Dynamic Chart Legend?

slam

Well-known Member
Joined
Sep 16, 2002
Messages
919
Office Version
  1. 365
  2. 2019
I have a 'Chart' worksheet that pulls data from AF2:AY37 on a worksheet called 'Drivers & Standings'

Row 2 is a header row (specifically AG2:AY2) that is used along the X axis of the chart. The drivers are listed in AF3:AF37, and it is the drivers names that are shown in my chart legend, but the list is dynamic and can also include blanks from ""

I have my chart ignoring blanks in the data range AG3:AY37 thanks to VoG, but I also need it to ignore, and not include in the Legend, cells in the drivers column that are blank from "".

Does anyone know how to go about this?

Thanks
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
For anyone interested, I was able to do this by making the chart data auto hide rows that had an error (because there was no data to calculate). I used this code from jonmo1 to do that and I now essentially have a dynamic chart legend that only shows items on the legend for which there is data:

Private Sub Worksheet_Calculate()
Dim MyRange As Range, C As Range
Application.EnableEvents = False
Set MyRange = Range("A1:A36") 'Adjust range as needed.

For Each C In MyRange
C.EntireRow.Hidden = IsError(C)
Next C

Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,134
Members
452,890
Latest member
Nikhil Ramesh

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