+ Reply to Thread
Results 1 to 5 of 5

Sum based on font color

  1. #1
    mario
    Guest

    Sum based on font color

    Is there a function which can sum up all the cells in a column where the
    contents of the cell are in pink color.

    Pls help.

    Thanks

  2. #2
    Forum Contributor
    Join Date
    03-03-2005
    Posts
    315
    try:

    Function SumByFontColor(ColorNum)

    set rng = ActiveSheet.UsedRange.rows
    For each c in rng
    If c.font.colorindex=ColorNum then
    s = s + c.value
    End if
    SumByColorFont= s

    End Function

  3. #3
    Forum Contributor
    Join Date
    03-03-2005
    Posts
    315
    try:

    Function SumByFontColor(ColorNum)

    Set rng = ActiveSheet.UsedRange.Rows
    rng.Select
    For Each c In Selection
    If c.Font.ColorIndex = ColorNum Then
    s = s + c.Value
    MsgBox s
    End If
    Next
    SumByFontColor = s

    End Function

  4. #4
    Patrick Molloy
    Guest

    RE: Sum based on font color

    something along these lines to get you started:

    Option Explicit
    Enum eColor
    Pink = 13408767
    End Enum
    Function ColorSum(Source As Range) As Double
    Dim total As Double
    Dim cell As Range
    For Each cell In Source
    With cell
    If .Font.Color = eColor.Pink Then
    total = total + .Value
    End If
    End With
    Next
    ColorSum = total
    End Function


    Enhancements:
    1) see if you can make the color a parameter
    2) add a check to ensure that a cell has a legitimate value befor totalling

    works as is though.


    "mario" wrote:

    > Is there a function which can sum up all the cells in a column where the
    > contents of the cell are in pink color.
    >
    > Pls help.
    >
    > Thanks


  5. #5
    Bob Phillips
    Guest

    Re: Sum based on font color

    See http://www.xldynamic.com/source/xld.ColourCounter.html

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "mario" <mario@discussions.microsoft.com> wrote in message
    news:1993969A-9B36-4758-8A4C-B4C3DD2E3DE0@microsoft.com...
    > Is there a function which can sum up all the cells in a column where the
    > contents of the cell are in pink color.
    >
    > Pls help.
    >
    > Thanks




+ 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