+ Reply to Thread
Results 1 to 3 of 3

Consistent coloring among multiple pie-charts with same attributes/ segments

  1. #1
    Registered User
    Join Date
    12-29-2009
    Location
    Milwaukee, US
    MS-Off Ver
    Excel 2007
    Posts
    25

    Consistent coloring among multiple pie-charts with same attributes/ segments

    Hi,

    I have test script statuses of scripts for two distinct Software Modules in an excel sheets. Each module's test scripts have following statuses:

    '1. Not Started'
    '2. In Progress'
    '3. Ready for Audit'
    '4. In Audit'
    '5. In rework'
    '6. Complete'
    '7. Removed'

    I've numbered them in sequence of script development life cycle. The main reason is because excel considers the sequence alphabetically. So, both modules have a pie-chart metric showing what is the '%' of each script status in the total inventory. I'm using the below macro.

    Sub ColorByCategoryLabel()
    Dim oChart As ChartObject
    Dim rPatterns As Range
    Dim iCategory As Long
    Dim vCategories As Variant
    Dim rCategory As Range
    Set rPatterns = ActiveWorkbook.Worksheets("DV Progress").Range("A159:A165")
    ' Loop through all charts on main page
    For Each oCht In ActiveWorkbook.Worksheets("DV Progress").ChartObjects
    With oCht.Chart.SeriesCollection(1)
    vCategories = .XValues
    ' Loop through all categories of chart,
    ' find and set color of matching category
    For iCategory = 1 To UBound(vCategories)
    Set rCategory = rPatterns.Find(What:=vCategories(iCategory))
    .Points(iCategory).Interior.ColorIndex = rCategory.Interior.ColorIndex
    Next
    End With
    Next
    End Sub

    It was working fine, but now I notice some colors not correct in the chart. So, I opened the vba editor (Ctrl+F11) and selected the macro and clicked on the 'play' button and got the Run-time error '91': Object variable or With block variable not set

    When I click on Debug, following line is highlighted:

    .Points(iCategory).Interior.ColorIndex = rCategory.Interior.ColorIndex

    Any clues..? Thanks !!

  2. #2
    Registered User
    Join Date
    12-29-2009
    Location
    Milwaukee, US
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Consistent coloring among multiple pie-charts with same attributes/ segments

    Hi All, does anyone know a solution to this issue? I'm not sure if all the variables are correctly defined and being used...Appreciate your help very much..!

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

    Re: Consistent coloring among multiple pie-charts with same attributes/ segments

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here


    It would help if you could post a workbook that demonstrates the error.

    Does the item being search for get found?
    Does the Point have a valid value?
    Cheers
    Andy
    www.andypope.info

+ 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