I am trying to write a code that will rename a chart. it needs to be able to locate the chart based of its top left cell, A1 for example. I’ve got the renaming portion of the code working but i cant seem to figure out how to work the the top left cell.
>Solution :
Please, test the next code:
Sub ChartChangeName()
Dim sh As Worksheet, ch As ChartObject
Set sh = ActiveSheet
For Each ch In sh.ChartObjects
If ch.TopLeftCell.Address = "$A$1" Then
ch.Name = "MyNewName": Exit For
End If
Next
End Sub