+ Reply to Thread
Results 1 to 10 of 10

Changine All Chart Line Colors to Same Color?

  1. #1
    Registered User
    Join Date
    06-17-2010
    Location
    So Cal
    MS-Off Ver
    Excel 2003
    Posts
    27

    Changine All Chart Line Colors to Same Color?

    How would I change all the line colors in a chart to be the same color? Clearly, manual approach is too cumbersome.

    I tried the following VBA but it is not working for me (Excel 2010):

    Please Login or Register  to view this content.
    Any help would be greatly appreciated. Thank you for reading.

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Changine All Chart Line Colors to Same Color?

    Because NumSeries is not defined. If you know the number of lines/series, add a line
    NumSeries = 52 (for example)
    I'm sure that there's a way to count the series and set it up that way but my VBA is so-so at best.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    06-17-2010
    Location
    So Cal
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: Changine All Chart Line Colors to Same Color?

    Quote Originally Posted by ChemistB View Post
    Because NumSeries is not defined. If you know the number of lines/series, add a line
    NumSeries = 52 (for example)
    I'm sure that there's a way to count the series and set it up that way but my VBA is so-so at best.
    Thanks ChenmistB. Unfortunately my VBA is even less than so-so. I actually thought NumSeries was a native function that counted the number of series in a chart. I did try to define it as you suggested but got a "Run-time error 424: Object required".

    Please Login or Register  to view this content.
    I've just done everything manually in the meantime but if anyone has any ideas, I would greatly appreciate them since I suspect this issue will come back to me soon.

  4. #4
    Forum Contributor
    Join Date
    04-01-2009
    Location
    Irvine, CA
    MS-Off Ver
    Excel 2010
    Posts
    280

    Re: Changine All Chart Line Colors to Same Color?

    I think you are trying to hard here...

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-17-2010
    Location
    So Cal
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: Changine All Chart Line Colors to Same Color?

    Quote Originally Posted by Chance2 View Post
    I think you are trying to hard here...

    Please Login or Register  to view this content.
    Thank you, Chance2. I am now getting a "Run-time error '9': Subscript out of range".

  6. #6
    Forum Contributor
    Join Date
    04-01-2009
    Location
    Irvine, CA
    MS-Off Ver
    Excel 2010
    Posts
    280

    Re: Changine All Chart Line Colors to Same Color?

    What line is giving you the error? Is Chart 5 the name of your chart sheet?
    Where are you calling the code from?

  7. #7
    Registered User
    Join Date
    06-17-2010
    Location
    So Cal
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: Changine All Chart Line Colors to Same Color?

    Quote Originally Posted by Chance2 View Post
    What line is giving you the error? Is Chart 5 the name of your chart sheet?
    Where are you calling the code from?
    Yes, I have confirmed that name of the chart even the space between "Chart" and "5". I am calling the macro simply from the macro list while I am on the sheet where the chart is located.

  8. #8
    Forum Contributor
    Join Date
    04-01-2009
    Location
    Irvine, CA
    MS-Off Ver
    Excel 2010
    Posts
    280

    Re: Changine All Chart Line Colors to Same Color?

    Can you "Step Into" the macro and press "F8" to walk through the steps until the error appears?

  9. #9
    Registered User
    Join Date
    06-17-2010
    Location
    So Cal
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: Changine All Chart Line Colors to Same Color?

    Quote Originally Posted by Chance2 View Post
    Can you "Step Into" the macro and press "F8" to walk through the steps until the error appears?
    Ah! I actually never used Step Into and F8 before so thank you for that. The error tripped on the line "Sheets("Chart 5").Activate" so it occurred to me to try typing in the sheet name rather than the chart name. That worked flawlessly!

    However, now I'm wondering if I can call it onto a specific named chart instead? I tried changing "Sheets" to "Chart" to no avail.

    In any event, thank you for the advice very much!

  10. #10
    Forum Contributor
    Join Date
    04-01-2009
    Location
    Irvine, CA
    MS-Off Ver
    Excel 2010
    Posts
    280

    Re: Changine All Chart Line Colors to Same Color?

    I believe your original code had the correct syntax for the chart: ActiveSheeet.ChartObjects("Chart 5").Activate
    As long as the ActiveSheet had the chart on it.

    Glad I could help!

+ 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