+ Reply to Thread
Results 1 to 14 of 14

How to Sum Cells based on Background Color?

  1. #1
    Registered User
    Join Date
    10-24-2019
    Location
    Estonia
    MS-Off Ver
    Office 10
    Posts
    11

    How to Sum Cells based on Background Color?

    I need a help, how I can Sum Cells based on Background Color?

    Screenshot 2020-01-21 at 18.15.23.png

    I need different sum orange and blue (and only A ja C columns).
    Like:
    A orange 230,84
    A blue 34,16

  2. #2
    Forum Contributor
    Join Date
    11-10-2017
    Location
    INDIA
    MS-Off Ver
    365
    Posts
    184

    Re: How to Sum Cells based on Background Color?

    Hi,

    You are very luck I have the function with me

    Please Login or Register  to view this content.
    Last edited by Sunny18pc; 01-21-2020 at 01:18 PM.
    *If you wish you click on *,a way to say ThankYou

  3. #3
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,743

    Re: How to Sum Cells based on Background Color?

    I believe that these colours are hard coded not from Conditional Formatting?
    If from CF Sunny's macro won't working and you are not be able to do it.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  4. #4
    Registered User
    Join Date
    10-24-2019
    Location
    Estonia
    MS-Off Ver
    Office 10
    Posts
    11

    Re: How to Sum Cells based on Background Color?

    Thank You, but how I can use this function?

  5. #5
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: How to Sum Cells based on Background Color?

    See attached
    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: How to Sum Cells based on Background Color?

    Quote Originally Posted by Sunny18pc View Post
    Hi,

    You are very luck I have the function with me

    Private Function CountCcolor(range_data As Range, criteria As Range) As Long
    Dim datax As Range
    Dim xcolor As Long
    xcolor = criteria.Interior.ColorIndex
    For Each datax In range_data
    If datax.Interior.ColorIndex = xcolor Then
    CountCcolor = CountCcolor + datax.value
    End If
    Next datax
    End Function
    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Last edited by FlameRetired; 01-21-2020 at 12:54 PM.
    Dave

  7. #7
    Forum Contributor
    Join Date
    11-10-2017
    Location
    INDIA
    MS-Off Ver
    365
    Posts
    184

    Re: How to Sum Cells based on Background Color?

    Hi real20,

    Open a new file and copy the code in VB and same the file as *.xlam

    Add addin under option menu >Add Addins and then you can use this formula in any sheet of excel.

    @FlameRetired - Missed to place # So sorry

  8. #8
    Registered User
    Join Date
    10-24-2019
    Location
    Estonia
    MS-Off Ver
    Office 10
    Posts
    11

    Re: How to Sum Cells based on Background Color?

    Almost works, but if there numbers like 58,22 then the number is only 58 and increase decimal donīt change nothing.

  9. #9
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: How to Sum Cells based on Background Color?

    Change declared CountCcolor to double rather than Long

  10. #10
    Registered User
    Join Date
    10-24-2019
    Location
    Estonia
    MS-Off Ver
    Office 10
    Posts
    11

    Re: How to Sum Cells based on Background Color?

    Sorry, I donīt understand.

  11. #11
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: How to Sum Cells based on Background Color?

    If you are using sunnys function change to
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    10-24-2019
    Location
    Estonia
    MS-Off Ver
    Office 10
    Posts
    11

    Re: How to Sum Cells based on Background Color?

    Iīm using nigelog function. What I have to change there?
    Attached Files Attached Files

  13. #13
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: How to Sum Cells based on Background Color?

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    10-24-2019
    Location
    Estonia
    MS-Off Ver
    Office 10
    Posts
    11

    Re: How to Sum Cells based on Background Color?

    Thank You!
    Now it works.

+ 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] Sum cells based on background color
    By Punxatawny in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-03-2018, 05:23 PM
  2. sum cells based on background color
    By Krueger in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 07-27-2017, 11:12 AM
  3. How to add cells just based on their color background?
    By meirelesj in forum Excel General
    Replies: 7
    Last Post: 07-28-2015, 07:04 AM
  4. Change cell background color based on another cells background color
    By Queo in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 4
    Last Post: 06-10-2014, 05:28 AM
  5. [SOLVED] Sum and average cells based on background color
    By Kaitlynn in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-22-2013, 12:51 PM
  6. [SOLVED] Color Index to sum up cells based on background color
    By jph89 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-16-2013, 03:23 PM
  7. Count Cells Based On A Background Color
    By NSTurk725 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-27-2010, 11:29 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