+ Reply to Thread
Results 1 to 6 of 6

Error 91 with Macro that Sets Fill and Line Color in Pivot Charts

  1. #1
    Registered User
    Join Date
    04-15-2018
    Location
    Mexicali, Baja California, Mexico
    MS-Off Ver
    2010 & 2016
    Posts
    18

    Question Error 91 with Macro that Sets Fill and Line Color in Pivot Charts

    Greetings

    I have a macro that sets the fill and/or line color of 4 different charts to either red, blue, or green.

    I recorded the macro as I performed the steps that I would take and this is the code that resulted.

    Please Login or Register  to view this content.

    But now I'm getting a Run-time error '91': Object variable or With Block variable not set.

    It highlights the first line of code "ActiveChart.FullSeriesCollection(1).DataLabels.Select" when I attempt to debug.

    I would really appreciate finding out what I'm missing here.

    Thanks a bunch in advance.

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Error 91 with Macro that Sets Fill and Line Color in Pivot Charts

    whole premise of your code is ActiveChart

    is the chart actually active when you activate the worksheet?
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    04-15-2018
    Location
    Mexicali, Baja California, Mexico
    MS-Off Ver
    2010 & 2016
    Posts
    18

    Re: Error 91 with Macro that Sets Fill and Line Color in Pivot Charts

    aww fudge...I didn't notice that, and also, it is not....how do I write the code if I simply want the fill and line color of the charts on a specific sheet to be the way they're coded above?

    this would have to work if someone is opening the workbook for the first time and or tabbing between sheets

    the whole purpose of this code is because excel insists on reformatting my charts with different colors

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Error 91 with Macro that Sets Fill and Line Color in Pivot Charts

    hmmm to be honest you have
    since you just recorded your code there is a lot in there you probably don't require

    all i actually see you want is
    format fill Color
    formal fill transparency
    Format LINE Color

    below is shortened code

    Please Login or Register  to view this content.
    Replace Chart 1 with whatever your chart is called
    Last edited by humdingaling; 03-26-2019 at 11:11 PM.

  5. #5
    Registered User
    Join Date
    04-15-2018
    Location
    Mexicali, Baja California, Mexico
    MS-Off Ver
    2010 & 2016
    Posts
    18

    Re: Error 91 with Macro that Sets Fill and Line Color in Pivot Charts

    Quick update:

    That code, humdingaling, worked somewhat well but Excel keeps fighting me on the fill and line colors.

    I'll keep at it and post the solution should I come upon it.

    Thanks for the help.

  6. #6
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Error 91 with Macro that Sets Fill and Line Color in Pivot Charts

    hmmm does not sound "normal"

    sounds like some other force at play to be forcing the change in charts on you
    cannot really tell just based on the code you have pasted

+ 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. Replies: 0
    Last Post: 03-31-2015, 02:50 AM
  2. [SOLVED] macro that sets background fill color on inserted data from button press
    By the block in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-29-2014, 03:25 PM
  3. [SOLVED] Change default chart in a macro to prevent run time error when creating a pivot charts
    By herbie226 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-14-2013, 10:01 AM
  4. Replies: 3
    Last Post: 08-28-2012, 09:16 AM
  5. Fill color between two XY line in chart in excel 2007
    By tomopaljk in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 12-31-2011, 06:26 PM
  6. Let me use the Line Color icon on charts
    By Stuart Bratesman in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 01-06-2006, 11:45 AM
  7. Conditional color fill whole line...
    By miwarren in forum Excel Formulas & Functions
    Replies: 31
    Last Post: 09-06-2005, 06:05 PM

Tags for this Thread

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