Hi, I'm a bit stumped by the following and was hoping somebody could help.
I'm looking to programmatically create a chart of the type shown on top in the attached image.
That is with the hours from 0 to 23 showing on the x-axis but not plotted as such.
When I try to create this programmatically using the code below the chart showing on the bottom is being produced.
Here's the simple code I am using:
Sub CreateChart()
Dim ws As Worksheet
Dim rng As Range
Dim cht As Object
For Each ws In ActiveWorkbook.Worksheets
ws.Activate
If InStr(ActiveSheet.Name, "Delivery") Then
Set cht = ActiveSheet.Shapes.AddChart2
Set rng = ActiveSheet.Range("B1:B25,E1:E25")
cht.Chart.SetSourceData Source:=rng
cht.Chart.ChartType = xlLine
End If
Next ws
End Sub
Same chart data range for both charts is showing in 'Select Data'. Both obviously xlLine charts.
The 2nd chart obviously has the 2nd series that I do not need. If I remove this series, the x-axis value continue to plot from 1 to 24
I'm probably missing something obvious but I cannot find what it is.
Thanks in advance for any advice.
Orson.
Bookmarks