+ Reply to Thread
Results 1 to 14 of 14

Runtime Error with Pie Chart Coloring Macro

  1. #1
    Registered User
    Join Date
    12-19-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    7

    Runtime Error with Pie Chart Coloring Macro

    Very new to VBA Macros, would really appreciate some help.

    Basically, I found (and tweaked to the best of my limited ability) the code below so that when I select a pie chart and run the macro "PieColors", it colors slices according to their labels. It seemed to work most of the time for the last few weeks, until this week.

    Suddenly one or two of slices in the list below ("none" for example) won't change color when the macro is run. I went back into the VBA editor and got the error, "Run-time error '91': Object variable or With Block variable not set" in the line beginning with "NumPoints = ActiveChart...". In my limited scope of knowledge of programming, I know that means I didn't define a variable somewhere (duh, right?), but I don't know what I need to do to fix it.

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

  2. #2
    Forum Contributor
    Join Date
    09-24-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: Runtime Error with Pie Chart Coloring Macro

    Did you select the chart before running the macro? also are all the case names in the chart you are trying to run the macro against?
    Last edited by moonsaga; 01-06-2014 at 04:19 PM.

  3. #3
    Registered User
    Join Date
    12-19-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Runtime Error with Pie Chart Coloring Macro

    Yes I did I knew I should've mentioned that in my initial post.

    The case names in the test chart are: "cpc", "banner", "organic", "(none)", "referral", and "Homepage Slider".

  4. #4
    Forum Contributor
    Join Date
    10-30-2013
    Location
    Melbourne
    MS-Off Ver
    Excel 2013
    Posts
    173

    Re: Runtime Error with Pie Chart Coloring Macro

    Either there is no active chart or it doesn't have a series(1)
    Just double check by inserting these lines before the line that errors

    Please Login or Register  to view this content.
    Both messages need to be False
    Last edited by coolblue; 01-06-2014 at 06:01 PM.

  5. #5
    Registered User
    Join Date
    12-19-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Runtime Error with Pie Chart Coloring Macro

    Quote Originally Posted by coolblue View Post
    There is no Count property for Points objects. That is why you have the error. At least I can't see one in the help
    So humor me here, how would I fix this to count the number of points, run the color test, etc.?

  6. #6
    Forum Contributor
    Join Date
    10-30-2013
    Location
    Melbourne
    MS-Off Ver
    Excel 2013
    Posts
    173

    Re: Runtime Error with Pie Chart Coloring Macro

    Sorry, my mistake!
    Check my edited post.

  7. #7
    Registered User
    Join Date
    12-19-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Runtime Error with Pie Chart Coloring Macro

    Both turned up false.

  8. #8
    Forum Contributor
    Join Date
    10-30-2013
    Location
    Melbourne
    MS-Off Ver
    Excel 2013
    Posts
    173

    Re: Runtime Error with Pie Chart Coloring Macro

    OK what about this...

    MsgBox ActiveChart.SeriesCollection(1).Points.Count

  9. #9
    Forum Contributor
    Join Date
    10-30-2013
    Location
    Melbourne
    MS-Off Ver
    Excel 2013
    Posts
    173

    Re: Runtime Error with Pie Chart Coloring Macro

    Sorry, I'm having a bad day... it should have been

    Please Login or Register  to view this content.
    And also add
    Please Login or Register  to view this content.
    Last edited by coolblue; 01-06-2014 at 06:28 PM.

  10. #10
    Registered User
    Join Date
    12-19-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Runtime Error with Pie Chart Coloring Macro

    MsgBox ActiveChart.SeriesCollection(1).Points.Count returns "6".

    The above returns "False", "False", and "False".

  11. #11
    Forum Contributor
    Join Date
    10-30-2013
    Location
    Melbourne
    MS-Off Ver
    Excel 2013
    Posts
    173

    Re: Runtime Error with Pie Chart Coloring Macro

    Quote Originally Posted by chrisdazzo View Post
    MsgBox ActiveChart.SeriesCollection(1).Points.Count returns "6".
    I which case, if it is the same as the code you pasted above and you inserted the message boxes just before the line throwing the error, it can't throw the error.

    Its like this?
    Please Login or Register  to view this content.
    Just to be proper, try declaring your variables properly, at least declare
    Please Login or Register  to view this content.
    I'm at a loss...

  12. #12
    Registered User
    Join Date
    12-19-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Runtime Error with Pie Chart Coloring Macro

    It's exactly the same as what was posted above.

    Oh well, thanks for trying to help :/

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

    Re: Runtime Error with Pie Chart Coloring Macro

    It would probably help if you posted an example workbook which illustrated the problem.

    See attached.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

  14. #14
    Registered User
    Join Date
    12-19-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Runtime Error with Pie Chart Coloring Macro

    This works great, thank you for taking the time, Andy!

    I'll be sure to post a working example next time, thanks for the tip.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Waterfall Chart with automatic coloring and text coloring
    By amartino44 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 07-19-2013, 05:54 PM
  2. Workbook_BeforePrint causes runtime 1004 error only on chart tab
    By AKL01 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 04-20-2012, 01:51 PM
  3. excel chart export error runtime 1004
    By Mau in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 08-17-2005, 07:05 AM
  4. [SOLVED] excel chart export error runtime 1004
    By Mau in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-04-2005, 05:05 PM
  5. RunTime Error 13 in Dynamically Creating a Chart
    By vkent in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-22-2005, 07:33 PM

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