Remove Empty Plots on Graph

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,074
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


6/3/2019199.869995202.699997196197.419998
6/4/2019200.839996223.369995200.5222.910004
6/5/2019224.580002234224.580002232.300003
6/6/2019233238.028224.360001237.259995
6/7/2019239250238.009995245.039993
6/10/2019249.360001257.130005247.479996249.880005
6/11/2019253.619995255.490005245.869995249.360001
6/12/2019237.399994245.789993231.649994242.199997
6/13/2019242.850006248.990005242.210007246.880005
6/14/2019243.639999246.880005240.759995244.940002
6/17/2019246.529999253.929993246.169998248.110001
6/18/2019252.570007255.5244.5245.179993
6/19/2019247.539993251.710007243.899994251.300003

<colgroup><col span="5"></colgroup><tbody>
</tbody>
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,213,530
Messages
6,114,162
Members
448,554
Latest member
Gleisner2

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