Results 1 to 3 of 3

Programmatically creating chart with hour value on X-axis but not plotted as a series

Threaded View

  1. #1
    Registered User
    Join Date
    04-16-2009
    Location
    Kilkenny, Ireland.
    MS-Off Ver
    Excel 365
    Posts
    47

    Programmatically creating chart with hour value on X-axis but not plotted as a series

    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.
    Attached Images Attached Images

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to order chart series when plotted on primary and secondary axis
    By Colin_in_Belgium in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 03-11-2021, 08:42 AM
  2. Replies: 3
    Last Post: 04-09-2018, 10:42 AM
  3. Replies: 5
    Last Post: 01-07-2017, 03:17 PM
  4. Replies: 2
    Last Post: 03-17-2014, 07:58 AM
  5. Area chart reverse fills when plotted on a secondary x-axis.
    By mrscut in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 07-03-2013, 04:38 AM
  6. Ensure Sensible Axis Scale When Creating Graphs Programmatically
    By chergh in forum Excel Charting & Pivots
    Replies: 8
    Last Post: 01-15-2010, 10:44 AM
  7. Hiding a non-plotted chart series in legend
    By Gromit in forum Excel General
    Replies: 0
    Last Post: 01-12-2006, 05:42 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1