Align Charts to Worksheet Grid Post 2
As a follow-up to Align Charts to Worksheet Grid Post 1, the following procedure assigns a name, sizes, and aligns all of the embedded charts on a single worksheet. The key to the procedure is the location (range address) of the cell at the top left side of the chart.
Sub AlignCharts()
Dim Cht As ChartObject
For Each Cht In ActiveSheet.ChartObjects
'Note: Naming the chart is optional.
Cht.Parent.Name = Cht.TopLeftCell.Offset(-1, 0).Value
Cht.Top = Cht.TopLeftCell.Top
Cht.Left = Cht.TopLeftCell.Left
Cht.Height = 114.75
Cht.Width = 192
Next Cht
End Sub
Given four embedded charts on a single sheet, the output looks like this:
Each chart is assigned the name of the value in the cell just above the top left cell. Each chart is aligned to the top-left cell and sized as per the height and width assignments.
With this procedure you don't have to worry about naming the charts first or building loops to place them. Just create a new chart, move it to the top-left cell location of your choice, add a name for the chart above the top-left cell, and run the macro.