Solution:
Alternative function to method WorkSheet.ChartObjects(chartObjectName).
The method WorkSheet.ChartObjects(chartObjectName) doesn't work doesn't return ChartObject which Name property contains character "-" (at least). Function below works correctly.
' returns ChartObject with name...
That works fine!
I need to do this (apart from other things):
Dim co as ChartObject, chartObjectName as String
Set co = ActiveSheet.ChartObjects(chartObjectName)
...
with given chartObjectName.
Apparently this code doesn't work for chartObjectName containing "-" character for the same...
The value of ActiveSheet.ChartObjects.Count is 2.
On the active sheet in Excel I can see Two chart objects. If I select each by clicking on it while holdinf Ctrl key, they have right names, see
Hi,
I'm trying to write some macro in VBA for Excel that manipulates with charts. I'm using ChartObject and I need to access them by name, so I rename them as shown in code sample below.
Sub test()
' add two new chart objects and name them
Dim co As ChartObject
Set co =...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.