PDA

View Full Version : VBA vertical major grid lines do not want to format as stated below



aolmos13
06-16-2015, 02:13 PM
I'm trying to include vba coding to format the primary vertical major gridlines to a black dash line. the following is the code with other formatting settings. It lets me format the horizontal major gridlines but the vertical ones stay a solid gray line

ActiveChart.ChartArea.Select
ActiveChart.SetElement (msoElementPrimaryCategoryGridLinesMajor)
ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
ActiveChart.SetElement (msoElementPrimaryValueAxisTitleRotated)
ActiveChart.Axes(xlCategory).Select
Selection.MajorTickMark = xlCross
Selection.MinorTickMark = xlInside
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 0, 0)
End With
With Selection.Format.Line
.Visible = msoTrue
.Weight = 2
End With
ActiveChart.Axes(xlValue).Select
Selection.MajorTickMark = xlCross
Selection.MinorTickMark = xlInside
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 0, 0)
End With
With Selection.Format.Line
.Visible = msoTrue
.Weight = 2
End With
ActiveChart.Axes(xlValue).MajorGridlines.Select
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 0, 0)
.Visible = msoTrue
.DashStyle = msoLineDash
End With
ActiveChart.ChartArea.Select
ActiveChart.PlotArea.Select
Selection.Format.Fill.Visible = msoFalse
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 0, 0)
End With