Public Sub AddEmbeddedChart()
Dim dataRange As Range
Set dataRange = ActiveWindow.Selection 'Chart selected data
ActiveSheet.ChartObjects.Add Left:=200, Top:=50, Width:=500,Height:=350
ActiveSheet.ChartObjects(1).Activate
With ActiveChart 'Set chart properties
.ChartType = xlColumnClustered
.SeriesCollection.NewSeries
.HasLegend = True
.Legend.Position = xlRight
.Axes(xlCategory).MinorTickMark = xlOutside
.Axes(xlValue).MinorTickMark = xlOutside
.Axes(xlValue).MaximumScale = Application.WorksheetFunction.RoundUp(Application.WorksheetFunction.Max(dataRange), -1)
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text ="X-axis Labels"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Y-axis"
.SeriesCollection(1).name = "Sample Data"
.SeriesCollection(1).Values = dataRange
End With
End Sub