I have some data that I'm putting into a chart and formatting. There are some business rules where some of the data is "Protected" like in the example. The issue when graphing with the word "Protected" (or any other word) excel is graphs that point at the bottom of the X-Axis. I'd like the graph to look like the 2nd chart, but I'd like to avoid graphing off a hidden column because I think it would confuse my power users.
Any thoughts or insights are appreciated!
Create a combo chart with a secondary axisClick anywhere in the chart you want to change to a combo chart to show the CHART TOOLS. Click DESIGN > Change Chart Type. On the All Charts tab, choose Combo, and then pick the Clustered Column - Line on Secondary Axis chart.
Select Range to Create a Graph from Workbook DataOnce the text is highlighted you can select a graph (which Excel refers to as chart). Click the Insert tab and click Recommended Charts on the toolbar. Then click the type of graph you wish to use.
Column Charts: Some of the most commonly used charts, column charts, are best used to compare information or if you have multiple categories of one variable (for example, multiple products or genres).
When manually building the chart:
Here are my results ...
A small bit of VBA that will generate the chart ...
Sub MakeChart()
Dim cell As Range, mySerRng As Range, mySrcRng As Range
Dim mySht As Worksheet, myChrt As Chart
Dim lastRow As Long
Set mySht = Worksheets("Sheet1")
lastRow = mySht.Range("A" & mySht.Rows.Count).End(xlUp).Row
Set mySerRng = mySht.Range(mySht.Cells(1, 2), mySht.Cells(lastRow, 2))
Set mySrcRng = mySht.Range(mySht.Cells(1, 1), mySht.Cells(lastRow, 2))
Set myChrt = mySht.Shapes.AddChart2(-1, xlLine, mySht.Range("C1").Left, mySht.Range("C1").Top).Chart
With myChrt
.SeriesCollection.Add Source:=mySrcRng, RowCol:=xlColumns, serieslabels:=True, categorylabels:=True, Replace:=True
For Each cell In mySerRng
If cell.Value = "Protected" Then
.SeriesCollection(1).Points(cell.Row - 1).Format.Line.Visible = False
.SeriesCollection(1).Points(cell.Row).Format.Line.Visible = False
End If
Next cell
End With
End Sub
Alternate approach
Build a scatter chart with multiple series, separated by the "offending" rows, and formatted so they appear to be one series ...
This has disadvantages:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With