+ Reply to Thread
Results 1 to 3 of 3

Calculate number of red values

Hybrid View

mubashar Calculate number of red values 01-31-2013, 09:49 AM
zbor Re: Calculate number of red... 01-31-2013, 10:04 AM
mubashar Re: Calculate number of red... 01-31-2013, 11:10 AM
  1. #1
    Registered User
    Join Date
    04-11-2012
    Location
    Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    96

    Calculate number of red values

    any function or statement through which i can calculate total number of values written in red .
    Attached Files Attached Files

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,074

    Re: Calculate number of red values

    Use this UDF:

    Function SumByColor(CellColor As Range, SumRange As Range)
    Dim myCell As Range
    Dim iCol As Integer
    Dim myTotal As Long
    iCol = CellColor.Font.ColorIndex ' get the target color
    For Each myCell In SumRange ' lok at each cell in the designated range
        'if the cell color matches the target color
        If myCell.Font.ColorIndex = iCol Then
                ' add the value in the cell to the total
            'If myCell >= iCol Then
            myTotal = WorksheetFunction.Sum(myCell) + myTotal
        'End If
        End If
    Next myCell
    SumByColor = myTotal
    End Function
    And in cell type:
    Formula: copy to clipboard
    =SumByColor(C3, $C$1:$C$9)


    Where C3 is example of cell you want to sum like (for example with red font, or with black font)
    and C1:C9 is a range to SUM
    Attached Files Attached Files
    Never use Merged Cells in Excel

  3. #3
    Registered User
    Join Date
    04-11-2012
    Location
    Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: Calculate number of red values

    Thanks for reply.... When i open the workbook it gives #NAME error ...... will you please solve it .

+ 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