+ Reply to Thread
Results 1 to 2 of 2

Add vertical / horizontal line to chart created with VBA

  1. #1
    Registered User
    Join Date
    04-05-2017
    Location
    Houston, TX
    MS-Off Ver
    2016
    Posts
    57

    Add vertical / horizontal line to chart created with VBA

    In another thread (https://www.excelforum.com/excel-pro...y-columns.html) I asked for advice on adding one series at a time to a chart created in VBA.

    Now I would like to add a horizontal (and eventually vertical) line to the chart. The existing code is:

    Please Login or Register  to view this content.
    How could I then add a horizontal line to the chart where the two y values are just the value stored in a single cell F1, the initial x value is 0 and the final x value is in cell F2?

    I've been trying to use a similar setup to the code above however I can't figure out how to add single x or y values to the series collection. I'm trying to avoid having to explicitly store x and y values in adjacent cells, especially since for the horizontal line the y values are simply the repetition of a single number.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,537

    Re: Add vertical / horizontal line to chart created with VBA

    How about using error bar(s). Instead of adding a new series consisting of two data points, add a new series consisting of a single X,Y data point, then add a horizontal error bar to that data point with the desired length. https://msdn.microsoft.com/en-us/lib.../ff821924.aspx
    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. [SOLVED] How to add a vertical line graph on a stacked horizontal bar chart?
    By Why123 in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 08-14-2015, 07:20 PM
  2. Straight Vertical and Horizontal line through a single scatter point.
    By jhall488 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 12-10-2012, 10:06 AM
  3. Display Vertical Data on one horizontal line
    By DMBeer41 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-13-2012, 05:38 PM
  4. Replies: 5
    Last Post: 01-29-2012, 09:48 PM
  5. Have horizontal bars--want to indicate average with vertical line....
    By sarahsez in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-10-2012, 04:51 AM
  6. Convert Horizontal Line Items to Vertical?
    By evo420 in forum Excel General
    Replies: 1
    Last Post: 01-26-2011, 06:51 PM
  7. Manually add fixed vertical horizontal line to chart
    By datacruncher in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 12-21-2009, 08:33 AM

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