Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 12th, 2018, 01:52 PM
Registered User
Join Date: Feb 2018
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Editing an XY chart in VBA

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 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"[/COLOR]
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?

Similar Threads
Thread Thread Starter Forum Replies Last Post
scatter XY chart using Script madganesh VBScript 0 June 13th, 2007 05:05 AM
Transfer of values from an object to an XY chart locusiste Excel VBA 0 April 23rd, 2004 05:02 PM
Editing Unlocked cells in VBA hems Excel VBA 1 April 16th, 2004 10:07 AM
Editing Unlocked cells in VBA hems VB How-To 0 April 14th, 2004 11:08 AM
Editing Unlocked cells in VBA hems VBScript 1 April 14th, 2004 10:42 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.