Remove Empty Plots on Graph

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,075
Office Version
  1. 2019
Platform
  1. Windows
I have this code that plots points on a graph. It works reasonable well except, it plots empty spaces that coincide with the weekends (Sat & Sun) (ex 06/07-06/10). Not sure why it does this, but I would like the chart to be seamless (Don't plot the empty spaces). Is this possible?

Thanks



Code:
Sub CreateCandlestick()    Dim nRows As Integer
    Dim ch As ChartObject


    nRows = Sheets("Data").UsedRange.Rows.Count


    'Delete existing charts


    For Each ch In Sheets("Parameters").ChartObjects
        ch.Delete
    Next


    nRows = Sheets("Data").UsedRange.Rows.Count


    'Create candlestick chart


    Dim OHLCChart As ChartObject
    Set OHLCChart = Sheets("Parameters").ChartObjects.Add(Left:=Range("i5").Left, Width:=400, Top:=Range("i5").Top, Height:=250)


    With OHLCChart.Chart
        .SetSourceData Source:=Sheets("Data").Range("a1:e" & nRows)
        .ChartType = xlStockOHLC
        .HasTitle = True
        .ChartTitle.Text = "Candlestick Chart for " & Sheets("Parameters").Range("ticker")
        .Axes(xlValue, xlPrimary).HasTitle = True
        .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Price"
        .HasLegend = False
        .PlotArea.Format.Fill.ForeColor.RGB = RGB(220, 230, 241)
        .ChartArea.Format.Line.Visible = msoFalse
        .Parent.Name = "OHLC Chart"
    End With
 
 End Sub


[TABLE="width: 445"]
<colgroup><col span="5"></colgroup><tbody>[TR]
[TD="align: right"]6/3/2019[/TD]
[TD="align: right"]199.869995[/TD]
[TD="align: right"]202.699997[/TD]
[TD="align: right"]196[/TD]
[TD="align: right"]197.419998[/TD]
[/TR]
[TR]
[TD="align: right"]6/4/2019[/TD]
[TD="align: right"]200.839996[/TD]
[TD="align: right"]223.369995[/TD]
[TD="align: right"]200.5[/TD]
[TD="align: right"]222.910004[/TD]
[/TR]
[TR]
[TD="align: right"]6/5/2019[/TD]
[TD="align: right"]224.580002[/TD]
[TD="align: right"]234[/TD]
[TD="align: right"]224.580002[/TD]
[TD="align: right"]232.300003[/TD]
[/TR]
[TR]
[TD="align: right"]6/6/2019[/TD]
[TD="align: right"]233[/TD]
[TD="align: right"]238.028[/TD]
[TD="align: right"]224.360001[/TD]
[TD="align: right"]237.259995[/TD]
[/TR]
[TR]
[TD="align: right"]6/7/2019[/TD]
[TD="align: right"]239[/TD]
[TD="align: right"]250[/TD]
[TD="align: right"]238.009995[/TD]
[TD="align: right"]245.039993[/TD]
[/TR]
[TR]
[TD="align: right"]6/10/2019[/TD]
[TD="align: right"]249.360001[/TD]
[TD="align: right"]257.130005[/TD]
[TD="align: right"]247.479996[/TD]
[TD="align: right"]249.880005[/TD]
[/TR]
[TR]
[TD="align: right"]6/11/2019[/TD]
[TD="align: right"]253.619995[/TD]
[TD="align: right"]255.490005[/TD]
[TD="align: right"]245.869995[/TD]
[TD="align: right"]249.360001[/TD]
[/TR]
[TR]
[TD="align: right"]6/12/2019[/TD]
[TD="align: right"]237.399994[/TD]
[TD="align: right"]245.789993[/TD]
[TD="align: right"]231.649994[/TD]
[TD="align: right"]242.199997[/TD]
[/TR]
[TR]
[TD="align: right"]6/13/2019[/TD]
[TD="align: right"]242.850006[/TD]
[TD="align: right"]248.990005[/TD]
[TD="align: right"]242.210007[/TD]
[TD="align: right"]246.880005[/TD]
[/TR]
[TR]
[TD="align: right"]6/14/2019[/TD]
[TD="align: right"]243.639999[/TD]
[TD="align: right"]246.880005[/TD]
[TD="align: right"]240.759995[/TD]
[TD="align: right"]244.940002[/TD]
[/TR]
[TR]
[TD="align: right"]6/17/2019[/TD]
[TD="align: right"]246.529999[/TD]
[TD="align: right"]253.929993[/TD]
[TD="align: right"]246.169998[/TD]
[TD="align: right"]248.110001[/TD]
[/TR]
[TR]
[TD="align: right"]6/18/2019[/TD]
[TD="align: right"]252.570007[/TD]
[TD="align: right"]255.5[/TD]
[TD="align: right"]244.5[/TD]
[TD="align: right"]245.179993[/TD]
[/TR]
[TR]
[TD="align: right"]6/19/2019[/TD]
[TD="align: right"]247.539993[/TD]
[TD="align: right"]251.710007[/TD]
[TD="align: right"]243.899994[/TD]
[TD="align: right"]251.300003[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

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