Total of shaded cells
Manage your personal finances in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Total of shaded cells

  1. #1
    New Member
    Join Date
    Mar 2002
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    I am trying to show the total of a number of shaded cells (all one colour) in a worksheet, scattered over a number of rows/columns. There is no conditional formatting, someone has highlighted the cells before sending to me. Please help!!!

  2. #2
    Board Regular Steve Hartman's Avatar
    Join Date
    Feb 2002
    Location
    Houston,Texas
    Posts
    417
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Veni, Vidi, Velcro - I came, I saw, I stuck around

    Taxation WITH representation ain't so hot either

  3. #3
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    You could search and find something like the following, but I wanted to add "application.volatile" to it to allow it to re-calc properly.

    Paste this custom function in a "normal" vba module:

    Function CountByColor(InputRange As Range, ColorRange As Range) As Double
    Dim cl As Range, TempCount As Double, ColorIndex As Integer
    Application.Volatile
    ColorIndex = ColorRange.Cells(1, 1).Interior.ColorIndex
    TempCount = 0
    On Error Resume Next
    For Each cl In InputRange.Cells
    If cl.Interior.ColorIndex = ColorIndex Then TempCount = TempCount + 1
    Next cl
    On Error GoTo 0
    Set cl = Nothing
    CountByColor = TempCount
    End Function



    Now use the following formula:

    =CountByColor(A3:A9,A1)

    Where the first paramter is the range to count and the second paramter (cell a1) has the color criteria to evaluate.


    Hope this helps. Cheers,

    Nate

    [ This Message was edited by: NateO on 2002-03-11 19:08 ]

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com