There is also a Non VBA solution that can also be controlled using VBA code. In excel, the data point represented by # N / A will not be displayed. Thus, you can use the formula - the simplest IF function, which returns the text #N/A as the text in the graph data. This data point will not be displayed, which means that you do not need to try to manipulate the format for it.
An example is to simply generate your graph data in a table and then replicate it below with a formula that just does it
=If(B2=0,"#N/A",B2)
This works if you want the chart lines to display, for example, the values ββ0.
source share