+ Reply to Thread
Results 1 to 2 of 2

Draw 3 points with 2 limit lines on a graph

  1. #1
    Registered User
    Join Date
    12-05-2016
    Location
    Massachusetts
    MS-Off Ver
    Office 2013
    Posts
    13

    Draw 3 points with 2 limit lines on a graph

    Hi,
    I need to do a graph with 3 points, avg, avg+x and avg-x values. Plus two horizontal lines for Min and Max limit values.
    I picked xlXYScatter for the type of graph, and I have 5 .NewSeries()
    I can draw the 2 limit lines, but when I try to do the 3 points, for each point I end up with two markers!!
    my code for the three points is below:

    Set avg = cht.SeriesCollection.NewSeries()
    Set avgplus = cht.SeriesCollection.NewSeries()
    Set avgminus = cht.SeriesCollection.NewSeries()

    With avg
    .Name = "avg"
    .XValues = Array(5, 0)
    .Values = Array(25, 5)
    .MarkerStyle = xlMarkerStyleX
    End With

    With avgplus
    .Name = "Avg+"
    .XValues = Array(5, 0)
    .Values = Array(27, 5)
    .MarkerStyle = xlMarkerStyleCircle
    End With

    With avgminus
    .Name = "Avg-"
    .XValues = Array(5, 0)
    .Values = Array(20, 5)
    .MarkerStyle = xlMarkerStyleTriangle
    End With

    I need the three markers on one X value, but different Y values..
    I picked 5, since I dont know how to assign a range to the X axis, since I only want to show 3 points vertically!!
    Also, how can I change the Markerstyle to be larger or bold??

    any help is appreciated.. this is the first time I am working with VBA graphing..so sorry for my ignorance

    thank you,
    Karen16

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Draw 3 points with 2 limit lines on a graph

    After a day, I will proffer a few thoughts:

    This forum can be strict about rules (including putting code tags around code). You will want to edit your post to include these code tags to avoid having your topic locked https://www.excelforum.com/misc.php?do=bbcode#code

    Since you say you are new to VBA graphing, I will suggest this help file: https://msdn.microsoft.com/VBA/Excel...s-object-excel I found that one of the things that really helped me early on was becoming familiar with Excel's object model (and the accompanying object, properties, and methods), as well as the help files that document the object model (Microsoft has never been excellent at putting help files together, but I found them helpful once I figure out how to use them more effectively). The linked file is to the series object help file, which includes links to the properties that apply to the series object, including the .xvalues property, the .values property (which should show you how to use a range instead of an array constant to define these), the .markerstyle property, and the .markersize property (which should explain how to change the size of the marker).

    I need the three markers on one X value, but different Y values.
    When I tested your code (adapted to the test sheet I created), this is what I got. I got three new data series, two points for each new series, and three points at each of the specified X values. I am not sure I understand your question here, though, since the code is syntactically correct, I wonder if this part of your question is more about the logic behind the programming rather than the programming itself.

    If this is not what you wanted, perhaps you were looking to add a single data series consisting of three points? Perhaps you were looking for
    Please Login or Register  to view this content.
    or perhaps 3 single point data series with a single point each?
    Please Login or Register  to view this content.
    Or something else?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to draw circle and points (from x-y data)
    By Hrki87 in forum Excel General
    Replies: 2
    Last Post: 10-31-2014, 04:42 AM
  2. Replies: 0
    Last Post: 02-06-2013, 02:08 PM
  3. Conditionally formatting the color of the lines connecting two points on a scatter graph
    By AtlasLion21 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-23-2012, 11:44 AM
  4. How to draw static vertical lines in Excel graph
    By vivekengg in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 05-03-2011, 10:04 AM
  5. Marking Data Points on a Graph that are Out of a control limit
    By Macro-wave in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 04-25-2009, 06:26 AM
  6. Replies: 6
    Last Post: 08-16-2008, 10:24 AM
  7. Automatically adding Vertical lines after certain points in line graph
    By matthoffman33 in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 03-06-2006, 09:50 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