+ Reply to Thread
Results 1 to 5 of 5

How can I change a chart's name?

  1. #1
    Berthica
    Guest

    How can I change a chart's name?

    I have a lot of charts in a woorkbook and need to refer to them in my VBA. I
    cannot know the names (numbers) of all the charts. mHow can I change a
    chart's name so it is easy to find them ?

  2. #2
    John Mansfield
    Guest

    RE: How can I change a chart's name?

    Berthica,

    These macros should help:

    Sub GetChartName()
    MsgBox "The chart name is: " & ActiveChart.Parent.Name
    End Sub

    Sub RenameChart()
    ActiveChart.Parent.Name = Chart1
    End Sub

    ----------------------------
    Regards,
    John Mansfield
    http://www.pdbook.com


    "Berthica" wrote:

    > I have a lot of charts in a woorkbook and need to refer to them in my VBA. I
    > cannot know the names (numbers) of all the charts. mHow can I change a
    > chart's name so it is easy to find them ?


  3. #3
    Debra Dalgleish
    Guest

    Re: How can I change a chart's name?

    John forgot the quote marks in his RenameChart macro:

    Sub RenameChart()
    ActiveChart.Parent.Name = "Chart1"
    End Sub


    Or, to rename a chart manually:

    Hold the Ctrl key, and click on the chart to select it
    Click in the Name Box, to the left of the formula bar
    Type a new name for the chart
    Press the Enter key


    John Mansfield wrote:
    > Berthica,
    >
    > These macros should help:
    >
    > Sub GetChartName()
    > MsgBox "The chart name is: " & ActiveChart.Parent.Name
    > End Sub
    >
    > Sub RenameChart()
    > ActiveChart.Parent.Name = Chart1
    > End Sub
    >
    > ----------------------------
    > Regards,
    > John Mansfield
    > http://www.pdbook.com
    >
    >
    > "Berthica" wrote:
    >
    >
    >>I have a lot of charts in a woorkbook and need to refer to them in my VBA. I
    >>cannot know the names (numbers) of all the charts. mHow can I change a
    >>chart's name so it is easy to find them ?

    >



    --
    Debra Dalgleish
    Excel FAQ, Tips & Book List
    http://www.contextures.com/tiptech.html


  4. #4
    Tushar Mehta
    Guest

    Re: How can I change a chart's name?

    While John and Debra have given you the technical solution, I don't know
    how useful they will be. You have to have some way to identify each of
    the charts *before* you rename them. Otherwise, how will you know what
    name to assign to what chart?

    --
    Regards,

    Tushar Mehta
    www.tushar-mehta.com
    Multi-disciplinary business expertise
    + Technology skills
    = Optimal solution to your business problem
    Recipient Microsoft MVP award 2000-2005

    In article <[email protected]>,
    [email protected] says...
    > I have a lot of charts in a woorkbook and need to refer to them in my VBA. I
    > cannot know the names (numbers) of all the charts. mHow can I change a
    > chart's name so it is easy to find them ?
    >


  5. #5
    John Mansfield
    Guest

    Re: How can I change a chart's name?

    Berthica,

    Tushar has a good point. Hopefully these macros will help too:

    If you're working with embedded charts, this will give you the name of each
    chart on the worksheet. You may need to add a different destination range.

    Sub ListChartNames()
    Dim Cht As ChartObject
    Dim Rng As Range
    Set Rng = ActiveSheet.Range("A1")
    For Each Cht In ActiveSheet.ChartObjects
    Rng.Value = Cht.Chart.Parent.Name
    Set Rng = Rng.Offset(1, 0)
    Next Cht
    End Sub

    This macro will rename each embedded chart in a sequential fashion if
    needed. If you have a lot of charts and need to create some kind of logic
    for naming them all, maybe this will help.

    Sub NameSequentialCharts()
    Dim Cht As ChartObject
    Dim i As Integer
    i = 1
    For Each Cht In ActiveSheet.ChartObjects
    Cht.Chart.Parent.Name = "Chart" & i
    i = i + 1
    Next Cht
    End Sub

    I forgot to mention before, for the first set of macros to work you much
    activate the embedded chart first.

    ----------------------------
    Regards,
    John Mansfield
    http://www.pdbook.com


    "Tushar Mehta" wrote:

    > While John and Debra have given you the technical solution, I don't know
    > how useful they will be. You have to have some way to identify each of
    > the charts *before* you rename them. Otherwise, how will you know what
    > name to assign to what chart?
    >
    > --
    > Regards,
    >
    > Tushar Mehta
    > www.tushar-mehta.com
    > Multi-disciplinary business expertise
    > + Technology skills
    > = Optimal solution to your business problem
    > Recipient Microsoft MVP award 2000-2005
    >
    > In article <[email protected]>,
    > [email protected] says...
    > > I have a lot of charts in a woorkbook and need to refer to them in my VBA. I
    > > cannot know the names (numbers) of all the charts. mHow can I change a
    > > chart's name so it is easy to find them ?
    > >

    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1