Chart creation macro recorder output

I turned on the macro recorder while I created a chart (shown in Figure 18-1) and then performed some simple customizations to it. The chart uses the data in range A1:F2.

Following in Listing 18-1 is the code generated by the macro recorder:

Listing 18-1: Code Generated by the Macro Recorder

Sub Macro1()

Range("A1:F2").Select Charts.Add

ActiveChart.ChartType = xlColumnClustered ActiveChart.SetSourceData _

Source:=Sheets("Sheet1").Range("A1:F2"), _ PlotBy:=xlRows ActiveChart.Location _

Where:=xlLocationAsObject, _ Name:="Sheet1" ActiveChart.HasLegend = False ActiveChart.ApplyDataLabels _

Type:=xlDataLabelsShowValue, LegendKey:=False ActiveChart.HasDataTable = False ActiveChart.Axes(xlCategory).Select Selection.TickLabels.Orientation = xlHorizontal ActiveChart.ChartTitle.Select Selection.Font.Bold = True Selection.AutoScaleFont = True With Selection.Font .Name = "Arial" .Size = 12

.Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False

.Underline = xlUnderlineStyleNone .Colorlndex = xlAutomatic .Background = xlAutomatic End With

ActiveChart.PlotArea.Select Selection.Top = 18 Selection.Height = 162 ActiveChart.ChartArea.Select ActiveChart.Axes(xlValue).Select With ActiveChart.Axes(xlValue) .MinimumScalelsAuto = True .MaximumScale = 0.6 .MinorUnitlsAuto = True .MajorUnitlsAuto = True .Crosses = xlAutomatic .ReversePlotOrder = False .ScaleType = xlLinear End With End Sub

Figure 18-1: This chart was created while Excel's macro recorder was turned on.
0 0

Post a comment