How to place a chart at a specific cell location within a worksheet. I am adding a chart using pivot table within the same sheet
and need to place the chart under the data.
The code I am using to add the chart is as follows, and it's working fine but I need to know if there is away to set the location by column# and row# eg. position (r1,c2) to set the chart under my pivot table in dynamic way
Sub sbPivotChart_SameSheet()
Dim pt As PivotTable, ptr As Range, Cht As Chart
If ActiveSheet.PivotTables.Count = 0 Then Exit Sub
Set pt = ActiveSheet.PivotTables(2)
Set ptr = pt.TableRange1
Set Cht = ActiveSheet.Shapes.AddChart.Chart
With cht.ChartArea
'adjust position and size (both in points) of the Chart Area:
.Width = 440
.Height = 300
.Left = 100
.Top = 100
End With
With Cht
.SetSourceData ptr
.ChartType = xlLine
End With
End Sub
Bookmarks