+ Reply to Thread
Results 1 to 13 of 13

Change chart type by using data validation

  1. #1
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Post Change chart type by using data validation

    Hi,

    Am I at all close on this.

    I have one chart and I want to cycle through 4 different types of charts using data validation.

    I used the macro recorder to get some of the syntax and added it under the Case “Ratio” to test, but not getting anything to happen.

    Can somebody help me out with the right way to go here?

    Please Login or Register  to view this content.
    Last edited by jeffreybrown; 11-27-2009 at 04:45 PM. Reason: Follow-up

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Change chart type by using data validation

    I confess I know little of working with Charts in VBA but I would point out that you need to use the Change event rather than SelectionChange event - ie you want the code to fire whenever C3 is altered.

    So instead of:

    Please Login or Register  to view this content.
    you would use

    Please Login or Register  to view this content.
    Other than that I can't really help much - it's not clear to me whether your trying to add and amend trend line types or the underlying chart type - it might help if you posted a sample file and perhaps provided examples of each chart that you wish to generate via the validation list.

    Hopefully Andy and co. will be able to help you resolve.

    (Probably worth just confirming that you are definitely using XL2007 - ie I suspect Charting options differ slightly between 2007 and predecessors)

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

    Re: Change chart type by using data validation

    You say chart type although the code would suggest you are changing Trendline type.

    If it's trendline then you can do it all with formula and multiple data series.

    Can you post example workbook.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Post Re: Change chart type by using data validation

    Hi Andy & DonkeyOte,

    Thank you for taking the time to help me here.

    Yes I am trying to change the trendline for an existing chart. Attached is an example workbook.
    Attached Files Attached Files

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

    Re: Change chart type by using data validation

    Additional series on data sheet.

    There are 4 new series in the chart. Each only displays a trendline.
    Attached Files Attached Files

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Post Re: Change chart type by using data validation

    Thank you so much Andy...perfect.

  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Post Re: Change chart type by using data validation

    Okay now that I am looking back at what you provided Andy, for the life of me I cannot figure out how the chart knows to change the trendline. I don't see how the change is passed to the chart other than you added the four series and the values that are NA() are invisible to the chart. Any thoughts?

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Change chart type by using data validation

    If I've got it right, Andy created four new series, each of which is the exact same data, and each has a diffferent type of trendline. Selecting a type of trendline makes three of the series #N/A, making it and its trendline disappear, leaving the selected one remaining.

    Andy is a very clever boy.
    Entia non sunt multiplicanda sine necessitate

  9. #9
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Post Re: Change chart type by using data validation

    Yes you've got it right that's how he set in up, but again still don't understand how the data left after selecting a particular chart knows what trendline to draw?

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Change chart type by using data validation

    Each of the series has a trendline -- four series, four trendlines. Only one series and its trendline are displayed at any given time.

  11. #11
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Post Re: Change chart type by using data validation

    Thanks so much

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

    Re: Change chart type by using data validation

    Shg's explanation is correct.

    The only extra thing I did was to format the extra 4 series to have no data markers. The data markers are from your original series, which now has no trendline.

  13. #13
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Post Re: Change chart type by using data validation

    Thank you Shg and Andy it is all making sense now.

+ 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