Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Vertical Line in an XY Chart at Today's Date

Is there an easy way to create a vertical line in an XY chart at today's
date assuming the 'X - axis' is populated with dates? Or any other way to
easily distinguish the history from the future? It would be neat if I could
change the background color to the left and right of the now() date.

I can create the vertical line using worksheet function and by adding
another series. It's just messy in my particular spreadsheet because of
other VBA code.

Thank you,
Chris



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Vertical Line in an XY Chart at Today's Date

Here is some code I wrote for work a few years ago.


InsideHeight = Satellite_Chart.PlotArea.InsideHeight
InsideLeft = Satellite_Chart.PlotArea.InsideLeft
InsideTop = Satellite_Chart.PlotArea.InsideTop
InsideWidth = Satellite_Chart.PlotArea.InsideWidth

LineLocation = (TodaysDate - StartDate) / (CurrentDate - StartDate)


Satellite_Chart.Shapes.AddLine(InsideLeft + (LineLocation * InsideWidth), _
InsideTop, _
InsideLeft + (LineLocation * InsideWidth), _
InsideTop + InsideHeight).Select

Selection.ShapeRange.Line.ForeColor.SchemeColor = 64
Selection.ShapeRange.Line.Visible = True

"C. Bailey" wrote:

Is there an easy way to create a vertical line in an XY chart at today's
date assuming the 'X - axis' is populated with dates? Or any other way to
easily distinguish the history from the future? It would be neat if I could
change the background color to the left and right of the now() date.

I can create the vertical line using worksheet function and by adding
another series. It's just messy in my particular spreadsheet because of
other VBA code.

Thank you,
Chris




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Vertical Line in an XY Chart at Today's Date

That line will never keep still. There are two ways to make a vertical line
that will stay where you put it. Both involve adding another series to the
chart. In one, add a series consisting of two points, both using the data
where you want it as X, the other using the minimum and maximum Y values.
Format this as an XY series with not markers but a connecting line. The
other approach needs a one-point series, where X = the date, and Y = either
the min or max, format the series to show no marker or lines, and add a
vertical error bar with a magnitude equal to the Y axis max minus min.

The techniques are as shown in this page for a column or line chart, but
easier for an XY chart:

http://peltiertech.com/Excel/Charts/AddLine.html

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Joel" wrote in message
...
Here is some code I wrote for work a few years ago.


InsideHeight = Satellite_Chart.PlotArea.InsideHeight
InsideLeft = Satellite_Chart.PlotArea.InsideLeft
InsideTop = Satellite_Chart.PlotArea.InsideTop
InsideWidth = Satellite_Chart.PlotArea.InsideWidth

LineLocation = (TodaysDate - StartDate) / (CurrentDate - StartDate)


Satellite_Chart.Shapes.AddLine(InsideLeft + (LineLocation *
InsideWidth), _
InsideTop, _
InsideLeft + (LineLocation *
InsideWidth), _
InsideTop + InsideHeight).Select

Selection.ShapeRange.Line.ForeColor.SchemeColor = 64
Selection.ShapeRange.Line.Visible = True

"C. Bailey" wrote:

Is there an easy way to create a vertical line in an XY chart at today's
date assuming the 'X - axis' is populated with dates? Or any other way
to
easily distinguish the history from the future? It would be neat if I
could
change the background color to the left and right of the now() date.

I can create the vertical line using worksheet function and by adding
another series. It's just messy in my particular spreadsheet because of
other VBA code.

Thank you,
Chris






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I convert a line chart to a vertical line chart in Excel Gerty Charts and Charting in Excel 1 August 20th 09 04:28 PM
Create vertical line to indicate date on chart with series of date ryguy7272 Charts and Charting in Excel 1 January 11th 08 06:36 PM
Vertical line in a histogram (vertical bar chart) AdamCPTD Excel Discussion (Misc queries) 0 July 13th 06 09:43 PM
Today's date as vertical line on a chart ChartQuestion Charts and Charting in Excel 1 June 1st 06 01:27 AM
How to add line at today's date in chart Xelc Excel Programming 7 February 9th 04 09:08 PM


All times are GMT +1. The time now is 04:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"