+ Reply to Thread
Results 1 to 3 of 3

Excel 2007 : Sum up cells by cell background color

Hybrid View

  1. #1
    Registered User
    Join Date
    01-02-2013
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Excel 2007 : Sum up cells by cell background color

    I am using the following formula:

    Function SumByColor(InputRange As Range, ColorRange As Range) As Double
    ' returns the sum of each cell in the range InputRange that has the same
    ' background color as the cell in ColorRange
    ' example: =SumByColor($A$1:$A$20,B1)
    ' range A1:A20 is the range you want to sum
    ' range B1 is a cell with the background color you want to sum
    Dim cl As Range, TempSum As Double, ColorIndex As Integer
        ' Application.Volatile ' this is optional
        ColorIndex = ColorRange.Cells(1, 1).Interior.ColorIndex
        TempSum = 0
        On Error Resume Next ' ignore cells without values
        For Each cl In InputRange.Cells
            If cl.Interior.ColorIndex = ColorIndex Then
                TempSum = TempSum + cl.Value
            End If
        Next cl
        On Error GoTo 0
        Set cl = Nothing
        SumByColor = TempSum
    End Function
    I used this in a spreadsheet I had for 2012 and just copied that same spreadsheet to use for 2013 and now my formula won't work. I remember when I first started using it in 2012, I had to hit some key to run the "macro" or formula but then it started doing it itself. How do I get the formula to start working again? I'm using the same cells/formulas as the old spreadsheet, I just updated the days of the year.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Excel 2007 : Sum up cells by cell background color

    hi shelmstr1, press [SHIFT+F9]

  3. #3
    Registered User
    Join Date
    01-02-2013
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Excel 2007 : Sum up cells by cell background color

    Thank you for the reply but that didn't seem to work. Somehow though, one of my rows started working so as long as I copy the cell contents from that row to the other rows I'm trying to add it seems to work.

+ 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