Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Renaming a chart while using its location to select it

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading