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
|