Automatically generating a chart without user interaction
Sub CreateChart(r)
Dim TempChart As Chart
Application.ScreenUpdating = False
Set CatTitles = ActiveSheet.range("A2:F2")
Set SrcRange = ActiveSheet.range(Cells(r, 1), Cells(r, 6))
Set SourceData = Union(CatTitles, SrcRange)
Set TempChart = Charts.Add
With TempChart
.ChartType = xlColumnClustered
.SetSourceData Source:=SourceData, PlotBy:=xlRows
.HasLegend = False
.ApplyDataLabels Type:=xlDataLabelsShowValue, _
LegendKey:=False
.ChartTitle.Font.Size = 14
.ChartTitle.Font.Bold = True
.Axes(xlValue).MaximumScale = 0.6
.Axes(xlCategory).TickLabels.Font.Size = 10
.Axes(xlCategory).TickLabels.Orientation = _
xlHorizontal
.Location Where:=xlLocationAsObject, name:="Sheet1"
End With
With ActiveSheet.ChartObjects(1)
.Width = 300
.Height = 150
.Visible = False
End With
End Sub
Related examples in the same category