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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
did you try #N/A as your null value ?
 
Upvote 0

Forum statistics

Threads
1,213,564
Messages
6,114,334
Members
448,567
Latest member
Kuldeep90

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