Remove Chart Legends Without Data

YCJ

New Member
Joined
Feb 28, 2011
Messages
29
Hi all

I have a template that I have done that will be filled with data after i run my macro. In the same template, but different worksheet, I have my chart that will collect the data to plot it out. I have reserved 60 columns in my template to store the data, and my chart will collect the data from those 60 columns. However, it is not necessary that I will have 60 data to fill in those columns, I might have only 35 data, depending on the user. In this case, my chart will have 25 legends without any data. My question is, can I remove those "empty" legends by making the 25 columns in my datasheet hidden using my macro??
Any guidance or any ideas are greatly appreciated....

Thanks,
CJ
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
To further clarify, I do not mean to hide the columns, as in "making them disappear", but to ".FormulaHidden = True", because I can't hide the whole columns, there's still a title on top of the page.

Thanks,
CJ
 
Upvote 0
I dont follow why you have so many legends - seem you will chart with a lot of unnecessary nothing - any hooottt

But go ahead and delete legends - dont have any effects - but you have to delete highest first

so something like code below -


Code:
    ActiveSheet.ChartObjects(NumCharts).Activate
    Dim Achart As ChartObject
    Set Achart = ActiveSheet.ChartObjects(NumCharts)
    
    With Achart.Chart
          'your code here
          For iii = 60 To 35 Step -1
            .Legend.LegendEntries(iii).Delete
          Next iii
    End With
 
Upvote 0
Hidding columns has no bearing on what is charted - you only hide them from Humans - not the code - unless you explicitly say so
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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