如何更改图表对象的名称,而不是将其称为ChartObject(1)?图表对象位于名为“ Unit2SelectedData”的工作表上
Sheets("Unit2SelectedData").ChartObjects.Add Left:=1700, Top:=50, Width:=800, Height:=400
Sheets("Unit2SelectedData").ChartObjects(1).Activate
答案 0 :(得分:3)
尝试首先设置ChartObject
,然后命名:
Dim ChtObj As ChartObject
Set ChtObj = Sheets("Unit2SelectedData").ChartObjects.Add(Left:=1700, Top:=50, Width:=800, Height:=400)
ChtObj.Name = "My Chart"