+ Reply to Thread
Results 1 to 6 of 6

Sum Cells with text in red by condicional formating

Hybrid View

  1. #1
    Registered User
    Join Date
    03-20-2010
    Location
    Portugal
    MS-Off Ver
    Excel 2019
    Posts
    69

    Sum Cells with text in red by condicional formating

    Hi, I have the following formula working, summing cells based in font color "red" that for this example is the number "255"

    But if the font color is based in a conditional formatting, the function doesn´t sum anything,

    I guess its assuming that there are no cells with red color, how can I make it work?

    Example in attach that should sum all the numbers in red: 5+6+7+8+9+10= 45


    thanks.


    Function SumRed(MyRange As Range)
    
    For Each cell In MyRange
            If cell.Font.Color = 255 Then
                SumRed = SumRed + cell.Value
            End If
        Next cell
    
    End Function
    Attached Files Attached Files
    Last edited by Blue_Wings; 07-03-2019 at 05:43 AM.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Sum Cells with text in red by condicional formating

    Simple if you use the CF condition in formula.

    In D1 Cell

    =COUNTIF(A1:A10,">5")


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    03-20-2010
    Location
    Portugal
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Sum Cells with text in red by condicional formating

    Sixthsense

    Thnaks for the help.

    The conditional formatting that I have is more complex, the ">5", that was just an example to understand why the function does not work.

    Its possible to sum cells taking in consideration the color gerated by the condicional formating?

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,307

    Re: Sum Cells with text in red by condicional formating

    Possibly...
    Function SumRed(MyRange As Range)
        
        For Each cell In MyRange
            If cell.FormatConditions.Item(1).Interior.Color = 255 Then
                If cell.DisplayFormat.Interior.Color = 255 Then
                    SumRed = SumRed + cell.Value
                End If
            End If
        Next cell
        
    End Function

  5. #5
    Registered User
    Join Date
    03-20-2010
    Location
    Portugal
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Sum Cells with text in red by condicional formating

    dangelor doesn´t work, but thanks anyway

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,709

    Re: Sum Cells with text in red by condicional formating

    You cannot detect CF colour using a UDF.
    You either need a macro, or use the CF rules to create a formula.

+ 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] Conditional Formating based on another cells value containing text and digits
    By mrteater in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-13-2015, 06:36 PM
  2. Replies: 3
    Last Post: 10-13-2011, 08:53 AM
  3. Condicional concatenation using values on separate sheets
    By kokotx1981 in forum Excel General
    Replies: 4
    Last Post: 09-28-2011, 12:13 AM
  4. Replies: 3
    Last Post: 06-02-2011, 11:03 AM
  5. Replies: 0
    Last Post: 11-28-2005, 06:55 AM
  6. [SOLVED] Formating text in cells
    By Mark J. Worden in forum Excel General
    Replies: 3
    Last Post: 06-09-2005, 06:05 PM
  7. merging cells and formating text.
    By Daniel M in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-19-2005, 05:07 AM

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