Make stop graph from having 0 values vba?

zaser

New Member
Joined
Aug 12, 2019
Messages
7
I'm trying to have a graph that doesn't chart 0 values. I'm using an array so I can change the value if it equals zero but I don't know what to change it to to make the chart not automatically graph it. Any help is appreciated.

This is my code that creates the array, assigns the series to it, and changes the values. Null still operates as zero which is kinda expected but unfortunate.

Dim ColumnData As Variant, c As Chart, s As Series, g As Integer
ReDim ColumnData(EndNumber - StartNumber)
g = 1
Set c = ActiveChart
'ReDim ColumnData(EndNumber - StartNumber)

'ColumnData = Range(Cells(StartNumber, 20), Cells(EndNumber, 29)).Value
For i = 20 To 28
Set s = c.FullSeriesCollection(g)
ColumnData = Range(Cells(StartNumber, i), Cells(EndNumber, i))

'MsgBox LBound(ColumnData)
For j = LBound(ColumnData, 1) To UBound(ColumnData, 1)
If ColumnData(j, 1) = 0 Then
ColumnData(j, 1) = Null
End If
Next j
s.Values = ColumnData
g = g + 1
Next i
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
did you try #N/A as your null value ?
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,816
Members
449,049
Latest member
cybersurfer5000

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