Microsoft Office Tutorials and References
In Depth Information
Recording a macro
Recording a macro
Figure 16-8 shows a simple column chart created from the data in A1:C7. The macro
recorder was turned on when this chart was created, moved, and resized. The
following macro is the result:
Sub Macro1()
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets(“Sheet1”).Range(“A1:C7”), _
PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:=”Sheet1”
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = “Chart Title”
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ActiveChart.HasLegend = False
ActiveSheet.Shapes(“Chart 1”).IncrementLeft -146.25
ActiveSheet.Shapes(“Chart 1”).IncrementTop -58.5
ActiveSheet.Shapes(“Chart 1”).ScaleWidth 0.65, msoFalse, msoScaleFromTopLeft
ActiveSheet.Shapes(“Chart 1”).ScaleHeight 0.75, msoFalse,
msoScaleFromTopLeft
End Sub
Figure 16-8: The macro recorder was turned on when this
chart was created and modified.
Search JabSto ::




Custom Search