Question

It is obviously possible to hide individual data points in an Excel line chart.

  • Select a data point.
  • Right click -> Format Data Point...
  • Select Patterns
  • Tab Set Line to None

How do you accomplish the same thing in VBA? Intuition tells me there should be a property on the Point object Chart.SeriesCollection(<index>).Points(<index> which deals with this...

Was it helpful?

Solution 2

"Describe it to the teddy bear" works almost every time...

You have to go to the Border child object of the Point object and set its LineStyle to xlNone.

OTHER TIPS

Actually if you are going to use SpyJournal's answer it has to be =IF(b2=0,NA(),b2), otherwise Excel just recognizes it as text, not as an 'official' #N/A

As a general tip: If you know how to do something in excel, but don't know how to do it in VBA you could just record a macro and look at the recorded VBA-code (works at least most of the time)

There is a Non VBA solution as well that can also be controlled from the VBA code as well. In excel a data point represented by a #N/A will not display. Thus you can use a formula - the easiest is an IF function - that returns an #N/A as text in the graph data. This data point will then not display which means you don't need to try and manipulate the format for it.

An example is simply to generate your graph data in a table, and then replicate it below with a formula that simply does this

=If(B2=0,"#N/A",B2)

This works when you want to stop line charts from displaying 0 values for example.

This is probably too late to be of assistance but the answer by SpyJournal, whilst easy and elegant,is slightly incorrect as it is necessary to omit the quotes around #N/A

Yes. It doesn't have to have the quotes to be a true not available cell content but for me N/A still plot as 0 in my charts.

The only way I can get it not to plot is to have the cell blank.

I tried "#N/A" with quotes in Excel 207 and as a result the data point is shown like a zero in the graph. It Works without the quotes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top