Applying chart formatting | VBA Excel @ ExcelOptimize.Com
Sub ChartMods()
ActiveChart.Type = xlArea
ActiveChart.ChartArea.Font.Name = “Calibri”
ActiveChart.ChartArea.Font.FontStyle = “Regular”
ActiveChart.ChartArea.Font.Size = 9
ActiveChart.PlotArea.Interior.ColorIndex = xlNone
ActiveChart.Axes(xlValue).TickLabels.Font.Bold = True
ActiveChart.Axes(xlCategory).TickLabels.Font.Bold = _
True
ActiveChart.Legend.Position = xlBottom
End Sub
You must activate a chart before executing the ChartMods macro. Activate an embedded chart by clicking it. To activate a chart on a chart sheet, activate the chart sheet.
To ensure that a chart is selected, you can add a statement to determine if a chart is active. Here’s the modified macro, which displays a message (and ends) if a chart is not activated:
Sub ChartMods2()
If ActiveChart Is Nothing Then
MsgBox “Activate a chart.”
Exit Sub
End If ActiveChart.Type = xlArea
ActiveChart.ChartArea.Font.Name = “Calibri”
ActiveChart.ChartArea.Font.FontStyle = “Regular”
ActiveChart.ChartArea.Font.Size = 9
ActiveChart.PlotArea.Interior.ColorIndex = xlNone
ActiveChart.Axes(xlValue).TickLabels.Font.Bold = True
ActiveChart.Axes(xlCategory).TickLabels.Font.Bold = _
True
ActiveChart.Legend.Position = xlBottom
End Sub

This post placed under VBA Excel , chart, format, VBA code by Andrian
Top incoming search terms for this post
You might wanna see also these VBA Excel :
Preventing Users from Inserting More Worksheets -
Preventing Users from Printing a Workbook -
Preventing Save As in a Workbook -
Loading Add-ins Automatically -
Do-Until loop -
Do-While loop -
Nested For-Next -

Leave a Reply