Share via

remove chart gridlines with vba

Anonymous
2012-02-12T03:15:39+00:00

I added this line of code to my module that creates my chart, and when I did, all of my font sizes jumped to 16.25 on the chart itself, although the vba code is still calling for the fonts to be set at 10.

I can't figure out why this is - I tried commenting out the added line of code, but my chart is still being created with the larger font.

 With ActiveChart

      .ChartType = xlColumnClustered

      .HasTitle = True

      .ChartTitle.Characters.Text = chartWS.Range(nameCell)

      .ChartTitle.Font.Size = 10

      .ChartTitle.Font.Bold = True

      .Axes(xlValue).MaximumScale = 1

     This is the added line of code: 

                                 .Axes(xlValue).MajorGridlines.Delete

      .PlotArea.Interior.ColorIndex = xlNone

      .Axes(xlValue).Select

         If .HasLegend = True Then

            .Legend.Position = xlLegendPositionTop

            .Legend.Font.Size = 10

            .Legend.Font.Bold = True

            .Legend.Position = xlLegendPositionTop

         End If

I sure would appreciate getting this fixed if anyone knows why the heck this is happening. Does not make any sense at all to me.

TIA

Joanne

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2012-02-12T10:33:24+00:00

Try turning off autoscaling for the chart.

Interactively:

  • Select the chart.
  • Select Format | Selected Chart Area.
  • Clear the check box Auto Scale.
  • Click OK.

In VBA:

ActiveChart.ChartArea.AutoScaleFont = False

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful