+ Reply to Thread
Results 1 to 11 of 11

Conditional formatting of charts.

  1. #1
    Registered User
    Join Date
    03-30-2007
    Posts
    72

    Conditional formatting of charts.

    I have a column chat that plots some positive and negative values. I would like for the positive columns to be one color and for the negative once a different color. Normally i would acomplish this by having 2 separate data sets one for the positive values and one for the negative once and then setting the color for them separately. My data however is pretty large at this point so i started to use a pivot table and i can either plot the pos values or the neg or all and all the columns are the same color. Does anyone know of a way to acomplish this?

  2. #2
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373
    Hi

    If I understood well you have a chart type Column with one only series, that has positive and negative values. You want the positive values in one colour and the negative values in another.

    If having just one series is really more convenient to you, I believe you have to run a vba snippet after the chart is drawn.

    It will be a small vba routine that:_
    - loops through the points of the series
    - for each point paints the column in a different colour depending on the value being positive or negative

    If you need help to write it, post details, like is the chart a sheet or is it embedded in a worksheet, the name of the chart if it's a sheet or of the chart object if it's embedded, if the chart really has only one series, etc.

    HTH
    lecxe

  3. #3
    Registered User
    Join Date
    03-30-2007
    Posts
    72
    i would apreciate some help in coding that. The chart is in a sheet the name is chart1 and the chart has only one series.
    Thank you!
    Last edited by shg; 11-03-2007 at 12:05 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373
    Hi

    This code paints the positive values in green and the negatives in red.
    Try:
    Please Login or Register  to view this content.
    HTH
    lecxe

  5. #5
    Registered User
    Join Date
    03-30-2007
    Posts
    72
    I get a subscript out of range error i guess because the code expects the chart to be embedded. It works fine for an embedded chart but using embedded charts causes my Excel 07 to crash frequently. Could you modify that for a chart that is in a regular sheet.
    Thank you very much for your help.
    Last edited by shg; 11-03-2007 at 12:05 PM.

  6. #6
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373
    Hi

    The code should work for a chart sheet.

    However, you can try an equivalent syntax, that rules out the confusion.

    Replace

    Please Login or Register  to view this content.
    with:

    Please Login or Register  to view this content.
    You should only get a a "subscript out of range error" if the name of the sheet is missplelled like "Chart 1" (with a space before the "1") instead of "Chart1".

    HTH
    lecxe

  7. #7
    Registered User
    Join Date
    03-30-2007
    Posts
    72
    I hate to be such a pain about this but i'm still getting the error. See pictures
    Attached Images Attached Images
    Last edited by shg; 11-03-2007 at 12:06 PM.

  8. #8
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373
    Hi

    I'm sorry that it's not working for you. I don't know why.
    Both versions work for me with no problem.

    Can you please run ans analyse this code?
    It may help understanding the problem:
    Please Login or Register  to view this content.
    Hope this helps to understand the problem
    lecxe

  9. #9
    Registered User
    Join Date
    03-30-2007
    Posts
    72
    Could not run the debug code . Got a subscript out of range referencing this line:
    Please Login or Register  to view this content.
    Last edited by shg; 11-04-2007 at 02:58 PM. Reason: deleted quote

  10. #10
    Registered User
    Join Date
    03-30-2007
    Posts
    72
    Found the solution
    I used this line

    Please Login or Register  to view this content.
    Thank you lecxe for your help, much apreciated

  11. #11
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373
    Hi

    I'm glad it works now.

    However, the line you use means it's not a chart sheet, it's a chart embedded in a worksheet, more precisely it's the first chart object in worksheet Table.

    Anyway the important thing is that your problem is solved.

    Cheers
    lecxe

+ 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