+ Reply to Thread
Results 1 to 7 of 7

Changing the legend of a chart based on a cell value

  1. #1
    Registered User
    Join Date
    01-28-2009
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    14

    Changing the legend of a chart based on a cell value

    How can i change the legend of a chart based on the value of a cell?

    Thanks
    Varun

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Changing the legend of a chart based on a cell value

    Hi Varun,

    the legend takes its text from the cell where the category description is stored. So you can change the category description in the data by using a formula that evaluates another cell and changes the category description accordingly, eg.

    =IF(A1=99,"This is the changed text","This is the default text")

    This is a simple true or false check. If you need something more complex, please post a sample workbook so we can have a better look.

    cheers

  3. #3
    Registered User
    Join Date
    01-28-2009
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Changing the legend of a chart based on a cell value

    Hi Teylyn,

    Thanks for the reply. Actually i want the legend to be copied from a cell which is being calculated and i don't know what it's value is.


    Thanks
    Varun

  4. #4
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Changing the legend of a chart based on a cell value

    Hi Varun,

    the principle is the same. You have a set of data somewhere, with the numbers that you want to graph. Include cells for the data categories in the graph, and they will show as the legend. Manipulate the cells that hold these category names to show what you want in the legend. If they take their value from a calculation that sits in another cell, just reference to this cell. say you have

    Please Login or Register  to view this content.
    and in cell X1 you have a calculation that comes up with a value like "mixed fruit". If you want to replace "pears" with whatever is calculated in X1, put

    =X1

    in cell A3

    Highlight A1 to B3, graph it, and whatever now shows up in A3 will be in the legend.

  5. #5
    Registered User
    Join Date
    01-28-2009
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Changing the legend of a chart based on a cell value

    Hi Teylyn,

    The legends which i need are:

    1. Time = 1 seconds
    2. Time = 4 seconds

    Here "1" and "4" are being calculated and stored in a cell. How do i do this?

    -Varun

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Changing the legend of a chart based on a cell value

    You just need to build the required legend text with formula.

    ="Time = " & F1 & " seconds"

    See attached where the legend uses the values from F1 and F2
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

  7. #7
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Changing the legend of a chart based on a cell value

    or you could have the number in the cell and use the custom number format

    0 "second(s)"

+ 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