DownBars and UpBars Members
Use the DownBars and UpBars objects to control the appearance of up and down bars on a chart. Use the ChartGroup object’s DownBars and UpBars properties to get a reference to these objects. The DownBars and UpBars objects have the following members:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The DownBars and UpBars objects are similar to the DropLines and HiLoLines objects. As with those objects, you can select, delete, or change the appearance of up and down bars. However, up and down bars have an interior region that you can control using two additional members: Fill and Interior. Be sure to check the ChartGroup object’s HasUpDownBars property before using these objects. The following code adds up and down bars to a chart and changes their appearance:
Sub DownBarsMembers( )
Dim chrt As Chart, cg As ChartGroup
' Get the chart.
Set chrt = ActiveChart
' Make it a line chart
chrt.ChartType = xlLine
' Get the chart group.
Set cg = chrt.LineGroups(1)
' Add down bars.
cg.HasUpDownBars = True
' Format the up and down bars.
On Error Resume Next
cg.UpBars.Interior.ColorIndex = 1
cg.DownBars.Interior.ColorIndex = 3
On Error GoTo 0
End SubYou should include the On Error Resume Next statement when working with up and down bars since the contents of the chart determine whether or not up bars, down bars, or both types of bars exist.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access