Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Illinois
    Posts
    552
    Thanks
    0
    Thanked 1 Time in 1 Post

    Name charts using VBA (Excel 2003)

    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.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Name charts using VBA (Excel 2003)

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

  3. #3
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Illinois
    Posts
    552
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Name charts using VBA (Excel 2003)

    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.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Name charts using VBA (Excel 2003)

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •