Sub VariWidthColumns()
'
Dim myChart As Chart
Dim rngData As Range
Dim lngIndex As Long
Dim zz As Series
Set rngData = Range("A1:N15")
Set myChart = ActiveSheet.ChartObjects.Add(650, 30, 620, 410).Chart
With myChart
.ChartType = xlArea
.SetSourceData Source:=rngData
For lngIndex = 1 To 4
With .SeriesCollection(lngIndex)
With .Format.Line
.Weight = 1
.Visible = True
.ForeColor.RGB = 0 ' black
End With
End With
Next
With .SeriesCollection(5)
.ChartType = xlLine
With .Format.Line
.Weight = 1
.Visible = True
.ForeColor.RGB = 255 ' red
.DashStyle = msoLineDash
End With
With .Points(1)
.HasDataLabel = True
With .DataLabel
.ShowValue = False
.ShowSeriesName = True
.ShowCategoryName = False
.Position = xlLabelPositionRight
.Font.Bold = True
.Font.Size = 10
.Font.Color = vbRed
End With
End With
End With
For lngIndex = 6 To 13 '5 to 12
With .SeriesCollection(lngIndex)
.ChartType = xlLine
.AxisGroup = 2
.HasDataLabels = True
With .DataLabels
.ShowValue = False
.ShowSeriesName = True
.ShowCategoryName = False
.Position = xlLabelPositionAbove
.Font.Bold = True
.Font.Size = 7.5
End With
End With
Next
With .Axes(xlCategory)
.CategoryType = xlTimeScale
.MaximumScale = 100
.MajorUnit = 10
.MinorUnit = 5
.MinorTickMark = xlOutside
.AxisBetweenCategories = False
.Format.Line.Weight = 2.25
.HasTitle = True
.AxisTitle.Text = "Share of total, %"
With .TickLabels
.NumberFormat = "# ##0"
.Font.Bold = True
End With
End With
With myChart.Axes(xlValue, xlPrimary)
.HasMajorGridlines = True
.MajorGridlines.Border.LineStyle = xlDash
.MinimumScale = 0
.MaximumScale = 10
.MajorUnit = 1
.MinorUnit = 0.5
.MinorTickMark = xlOutside
.Format.Line.Weight = 2.25
With .TickLabels
.NumberFormat = "# ##0"
.Font.Bold = True
End With
.HasTitle = True
.AxisTitle.Text = "Value Axis"
End With
With myChart.Axes(xlValue, xlSecondary)
.HasMajorGridlines = True
.MajorGridlines.Border.LineStyle = x1Dash
.MinimumScale = 0
.MaximumScale = 10
.MajorUnit = 1
.MinorUnit = 0.5
.MinorTickMark = xlOutside
.Format.Line.Weight = 2.25
With .TickLabels
.NumberFormat = "# ##0"
.Font.Bold = True
End With
.HasTitle = False
'.AxisTitle.Text = "Value Axis"
End With
.DisplayBlanksAs = xlNotPlotted
.Legend.Delete
End With
End Sub
you has x1Dash rather than xlDash. (1 one rather than l L)
you need to change chart type of 5th series to line
those new series data labels are at the top of the chart
Bookmarks