+ Reply to Thread
Results 1 to 4 of 4

problem counting based on cell colour

Hybrid View

thedon_1 problem counting based on... 09-28-2012, 08:03 AM
patel45 Re: problem counting based on... 09-28-2012, 08:15 AM
thedon_1 Re: problem counting based on... 09-28-2012, 08:46 AM
patel45 Re: problem counting based on... 09-28-2012, 10:56 AM
  1. #1
    Forum Contributor
    Join Date
    09-05-2007
    Posts
    148

    problem counting based on cell colour

    I have this UDF which counts the number of cells with a specific colour.

    Function CountColour(rColor As Range, rCOuntRange As Range)
    
    Dim rCell As Range
    Dim iCol As Integer
    Dim vResult
    
    iCol = rColor.Interior.ColorIndex
    
    For Each rCell In rCOuntRange
    If rCell.Interior.ColorIndex = iCol Then
    vResult = vResult + 1
    End If
    Next rCell
    
    CountColour = vResult
    End Function
    It works fine unless the colours are very similar to each other. Why is this? Any way to sort it out?

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: problem counting based on cell colour

    check vba help for colorindex, it can see only 56 colors
    If solved remember to mark Thread as solved

  3. #3
    Forum Contributor
    Join Date
    09-05-2007
    Posts
    148

    Re: problem counting based on cell colour

    Thanks for that.

    Is there a way to take into account all colours?

    Failing that, is there any easy way of telling a user which colours are within the 56 so they only use those?

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: problem counting based on cell colour

    try using rCell.Interior.Color (RGB colors)

+ 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