• Name charts using VBA (Excel 2003)

    Author
    Topic
    #422680

    I have 94 chart worksheets in an Excel file. I want to ‘name’ the charts the same name as their worksheet name. How do I iterate through all of them applying this name to the sheets.

    Thank you for the help.

    Viewing 0 reply threads
    Author
    Replies
    • #964758

      Sheets must have unique names, a chart sheet cannot have the same name as a worksheet. Or do I misinterpret your question?

      • #964760

        oh, sorry. I mean the actual chart on the chart sheet. I need to “name” this chart because it gets paste linked into a powerpoint file and I need to access the chart by it’s name in powerpoint.

        • #964763

          No, my fault. I didn’t read your post carefully enough. The following code will rename the first chart object on each worksheet:

          Sub NameCharts()
          Dim wsh As Worksheet
          On Error Resume Next
          For Each wsh In ActiveWorkbook.Worksheets
          wsh.ChartObjects(1).Name = wsh.Name
          Next wsh
          Set wsh = Nothing
          End Sub

          The On Error Resume Next avoids problems with sheets that don’t contain a chart.

    Viewing 0 reply threads
    Reply To: Reply #964763 in Name charts using VBA (Excel 2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel