Selasa, 03 November 2015

Re: [ExcelVBA] Pivot Table & Color Counting


I suspect the colour in the pivot table is conditional formatting.  This is not the Interior.Color of the cell.  If this is the problem you may have to uase the number value to identify the relevant cells.

I would put debug.pprint statements in the code to test the values like

Debug.Print CellColor.address
Debug.Print CellColor.Interior.ColorIndex

And see what you are looking at.

David Grugeon

On 4 November 2015 at 12:22, [ExcelVBA] <> wrote:


I have a macro for counting colors that works on a normal worksheet.

Problem:  Clever created Pivot table with colors(Green, Red, Black..etc) that have numbers and text when you hover over the color

Example: When cursor is over the Green value = 5(RED = 3) with text for the source data column and description

Problem #2:  I was attempting to use the Color Macro for 2 days w/ no luck while placing the colors in other blocks outside of the pivot.  It worked outside of the pivot table.

Any ideas on why the Color Macro is not working.  The Macro is down below:



Here is the Macro:

Function CountByColor(CellColor As Range, CountRange As Range)
Dim ICol As Integer
Dim TCell As Range
ICol = CellColor.Interior.ColorIndex
For Each TCell In CountRange
    If ICol = TCell.Interior.ColorIndex Then
        CountByColor = CountByColor + 1
    End If
Next TCell
End Function


Posted by: David Grugeon <>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: to enter the ezine, then search the ARCHIVES for EXCEL VBA.

Visit our ExcelVBA group home page for more info and support files:

More free tutorials and resources available at:




Tidak ada komentar:

Posting Komentar