Results 1 to 4 of 4

Help with XY charts

Threaded View

shdgv Help with XY charts 02-12-2018, 02:01 PM
MrShorty Re: Help with XY charts 02-12-2018, 05:41 PM
shdgv Re: Help with XY charts 02-12-2018, 06:07 PM
MrShorty Re: Help with XY charts 02-12-2018, 06:28 PM
  1. #1
    Registered User
    Join Date
    02-12-2018
    Location
    canada
    MS-Off Ver
    2016
    Posts
    2

    Help with XY charts

    I want to plot a bunch a of data in VBA. my X axis is in "YYYY/MM/DD h:mm" format. when I plot it using XLline, it plots all the data from different times of one day under one X tang based on one day. for example it shows two vertical lines for dozens of data for two different days.
    when I change the graph type to XLxyscatter, the problem is solved but I have no control on editing the chart as I need to control the minimum-maximum of Y axis and major units on X axis.

    here is my code:
    Dim h2s As ChartObject
    Dim h2ss As Chart
    Dim h2sso As SeriesCollection
    Dim h2sso2 As Series
    Set h2s = Sheet3.ChartObjects.Add(Range("a1").Left, Range("A56").Top, 479, 300)
    h2s.Name = "Air/ Acid gas flow"
    Set h2ss = h2s.Chart
    With h2ss
    .HasLegend = False
    .HasTitle = True
    .ChartTitle.Text = "H2S + SO2 in Tailgas"
    *******************
    Dim rng3 As Range
    Dim sds4 As Double
    Set rng3 = Sheets(2).Range(Sheets(2).Cells(2, 16), Sheets(2).Cells((finishdate - startdate), 16))
    sds4 = Application.WorksheetFunction.Min(rng3)
    sdss2 = Application.WorksheetFunction.Max(rng3)
    .Axes(xlValue).MinimumScale = (sds4 - (sds4 * 0.1))
    .Axes(xlValue).MaximumScale = (sdss2 + sdss2 * 0.1)
    .Axes(xlCategory).TickLabels.NumberFormat = "m/d/yyyy h:mm"
    ************************
    Set h2sso = .SeriesCollection
    Set h2sso2 = h2sso.NewSeries
    With h2sso2
    .Name = "H2S+SO2 in Tailgas"
    .XValues = Sheets(1).Range(Sheets(1).Cells(startdate, 1), Sheets(1).Cells(finishdate, 1))
    .Values = Sheets(2).Range(Sheets(2).Cells(2, 16), Sheets(2).Cells((finishdate - startdate), 16))
    
    .ChartType = xlXYScatterLines
    
    End With
    End With
    Basically when I choose XLxyscatter the part between starts is not run. Can someone help me please?
    Attached you can see the Xlline and XYscatter results from the code.
    scatter.jpg
    line.jpg
    Last edited by shdgv; 02-12-2018 at 06:03 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 32
    Last Post: 07-17-2018, 03:08 AM
  2. VBA charts update - dynamically test sheet type for two types of charts
    By kapucino in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-07-2017, 07:00 AM
  3. [SOLVED] Vary Colors in Pivot Charts based on values (Overlay Charts)
    By TitansGo in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 01-18-2017, 04:36 PM
  4. Replies: 0
    Last Post: 10-12-2015, 03:25 AM
  5. Replies: 2
    Last Post: 09-15-2015, 04:12 AM
  6. copying multiple charts from excel to word overwriting previous charts
    By eric45 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-01-2013, 11:11 AM
  7. Creating simple charts from multiple pivot table charts
    By hovaucf in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-23-2008, 04:13 PM

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