+ Reply to Thread
Results 1 to 2 of 2

Help Count Color Cells in a Pivot Table

  1. #1
    Registered User
    Join Date
    07-13-2014
    Location
    Portugal
    MS-Off Ver
    2010
    Posts
    8

    Help Count Color Cells in a Pivot Table

    Hello Everyone,

    I have a pivot table that contains a Conditional Formatting, this formatting puts the cells white to red. I have a VBA Code which will count the cells but inside the pivot table not recognizes the count of the red cells.

    This is the Code i´m using. I need your help

    Thank you!

    Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As Boolean)
    Dim rCell As Range
    Dim lCol As Long
    Dim vResult
    lCol = rColor.Interior.ColorIndex
    If SUM = True Then
    For Each rCell In rRange
    If rCell.Interior.ColorIndex = lCol Then
    vResult = WorksheetFunction.SUM(rCell, vResult)
    End If
    Next rCell
    Else
    For Each rCell In rRange
    If rCell.Interior.ColorIndex = lCol Then
    vResult = 1 + vResult
    End If
    Next rCell
    End If
    ColorFunction = vResult
    End Function

  2. #2
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,256

    Re: Help Count Color Cells in a Pivot Table

    VBA can't count cells that are coloured by conditional formatting.
    This has noting to do with a pivot table.
    Try using the conditional format formule for counting the red cells.
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

+ 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. [SOLVED] undesirable change of cells color when expanding/collapsing pivot table
    By ivansamsonov in forum Excel Charting & Pivots
    Replies: 14
    Last Post: 05-28-2013, 09:34 AM
  2. Need to count Blank cells instead of data cells in Pivot table
    By plb999 in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 11-19-2012, 09:01 PM
  3. Color Count in conditional formatting in pivot table
    By mangeshp4 in forum Excel General
    Replies: 4
    Last Post: 10-15-2010, 07:52 AM
  4. Change the color of cells in the pivot table
    By minrufeng in forum Excel General
    Replies: 0
    Last Post: 03-14-2006, 04:18 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