Mega Code Archive

 
Categories / VisualBasic Script / Excel
 

To ensure that a chart is selected, you can add a statement to determine if a chart is active

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