+ Reply to Thread
Results 1 to 2 of 2

Sum cells based on background color

  1. #1
    Registered User
    Join Date
    06-23-2017
    Location
    Fort Collins, CO
    MS-Off Ver
    Office 2010
    Posts
    29

    Sum cells based on background color

    Yesterday I found this UDF designed to sum only the cell that match a specific background color.

    Please Login or Register  to view this content.
    For some reason it's rounding the result instead of giving a true sum. I assume it has something to do with the line "Dim ColIndex As Integer" but I am clueless about how to read this code. Other than the rounding it works great, can someone please tell me what to change so that it provides the real sum and not a rounded integer?
    Last edited by Punxatawny; 10-03-2018 at 05:06 PM.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,594

    Re: Sum cells based on background color

    Change Dim cSum As Long to: Dim cSum As Double. LONG is for whole numbers (integers) DOUBLE is for decimals (0.0).

    Also, you don't need worksheetfunction...
    just:
    cSum = cSum + cl.value
    Last edited by protonLeah; 10-03-2018 at 05:27 PM.
    Ben Van Johnson

+ 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. sum cells based on background color
    By Krueger in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 07-27-2017, 11:12 AM
  2. 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
  3. 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
  4. [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
  5. [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
  6. Replies: 3
    Last Post: 05-02-2012, 09:08 AM
  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