Results 1 to 2 of 2
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Jacksonville,NC, USA
    Posts
    705
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: RESOLVED

    Nevermind...I found it...I just had to rewrite the formula as Ozgrid explained further in his directives:

    =ColorFunction(C1,$A$1:$A$12,TRUE)

    Making the Boolean statement True instead of False, or empty
    NMP <img src=/S/cool.gif border=0 alt=cool width=15 height=15>

    If you can't convince them, confuse them. - Harry Truman <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

  2. #2
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Jacksonville,NC, USA
    Posts
    705
    Thanks
    0
    Thanked 0 Times in 0 Posts

    RESOLVED: Count or Sum Macro Question (Excel 2003)

    I have some code as follows I am using from the Ozgrid site: (My question is: It seems to count the cells that have color, but does not sum them. What would have to be tweaked to sum them as SUM is already being used in the code, I'm confused.)

    Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As Boolean)
    Dim rCell As Range
    Dim lCol As Long
    Dim vResult

    ''''''''''''''''''''''''''''''''''''''
    'Written by Ozgrid Business Applications
    'www.ozgrid.com

    'Sums or counts cells based on a specified fill color.
    '''''''''''''''''''''''''''''''''''''''

    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
    Attached Files Attached Files
    NMP <img src=/S/cool.gif border=0 alt=cool width=15 height=15>

    If you can't convince them, confuse them. - Harry Truman <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •