Results 1 to 5 of 5

UDF SumByColor but won't add up the decimals

Threaded View

Megan52843 UDF SumByColor but won't add... 07-08-2015, 01:13 PM
JieJenn Re: UDF SumByColor but won't... 07-08-2015, 01:17 PM
Megan52843 Re: UDF SumByColor but won't... 07-08-2015, 01:28 PM
sktneer Re: UDF SumByColor but won't... 07-08-2015, 01:22 PM
sktneer Re: UDF SumByColor but won't... 07-08-2015, 01:46 PM
  1. #1
    Registered User
    Join Date
    07-08-2015
    Location
    MD, USA
    MS-Off Ver
    8
    Posts
    2

    Question UDF SumByColor but won't add up the decimals

    Hello!

    I created a UDF called SumByColor. It sums all the numbers that are in a particular colored cell of your choosing. It's working, however it sums the numbers up to a whole number instead of including the decimals. Here is my function:

    Function SumByColor(CellColor As Range, rRange As Range)
    Dim cSum As Long
    Dim ColIndex As Integer
    ColIndex = CellColor.Interior.ColorIndex
    For Each cl In rRange
        If cl.Interior.ColorIndex = ColIndex Then
            cSum = WorksheetFunction.Sum(cl, cSum)
        End If
    Next cl
    SumByColor = cSum
    End Function
    How can I get it to sum up the numbers including the decimals places?

    Thank you!
    Last edited by Megan52843; 07-08-2015 at 01:33 PM. Reason: SOLVED and formatted code per the rules

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Trying to get SumByColor working
    By Deathwing in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-07-2014, 10:02 AM
  2. [SOLVED] Countif + SumByColor
    By sordid in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 07-11-2014, 05:55 AM
  3. [SOLVED] SumByColor(Rng)
    By JimMay in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2006, 07:45 AM
  4. [SOLVED] how to use sumbycolor fuction?
    By Ghauri in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-29-2005, 05:10 PM
  5. [SOLVED] SumByColor Macro...
    By Murph in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-28-2005, 07:05 PM

Tags for this Thread

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