+ Reply to Thread
Results 1 to 5 of 5

Sum all cells with interior color...

  1. #1
    Forum Contributor
    Join Date
    10-03-2005
    Posts
    183

    Sum all cells with interior color...

    Hi

    I'm trying to make a macro which will sum all the cells which have a special interior color.

    However I don't know how to sum these cells. I will also need to check if the Cell contains a number (ISNUMBER).

    Do anyone know how I can do this,

    As always thanks.


    For Each Cell In Selection
    On Error Resume Next
    If Cell.Interior.ColorIndex = 36 Then
    If Cell = ISNUMBER then
    End if


    End If

    Next Cell

  2. #2
    Bob Phillips
    Guest

    Re: Sum all cells with interior color...

    See http://www.xldynamic.com/source/xld.ColourCounter.html for a complete
    solution.

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "Ctech" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi
    >
    > I'm trying to make a macro which will sum all the cells which have a
    > special interior color.
    >
    > However I don't know how to sum these cells. I will also need to check
    > if the Cell contains a number (ISNUMBER).
    >
    > Do anyone know how I can do this,
    >
    > As always thanks.
    >
    >
    > For Each Cell In Selection
    > On Error Resume Next
    > If Cell.Interior.ColorIndex = 36 Then
    > If Cell = ISNUMBER then
    > End if
    >
    >
    > End If
    >
    > Next Cell
    >
    >
    > --
    > Ctech
    > ------------------------------------------------------------------------
    > Ctech's Profile:

    http://www.excelforum.com/member.php...o&userid=27745
    > View this thread: http://www.excelforum.com/showthread...hreadid=500327
    >




  3. #3
    Norman Jones
    Guest

    Re: Sum all cells with interior color...

    Hi Ctech,

    Try:

    '=============>>
    Public Sub Tester091()
    Dim rng As Range
    Dim rCell As Range
    Dim myVal As Double

    Set rng = Selection

    For Each rCell In rng.Cells
    If rCell.Interior.ColorIndex = 36 Then
    If Application.IsNumber(rCell.Value) Then
    myVal = myVal + rCell.Value
    End If
    End If
    Next rCell

    MsgBox myVal

    End Sub
    '<<=============


    ---
    Regards,
    Norman


    "Ctech" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi
    >
    > I'm trying to make a macro which will sum all the cells which have a
    > special interior color.
    >
    > However I don't know how to sum these cells. I will also need to check
    > if the Cell contains a number (ISNUMBER).
    >
    > Do anyone know how I can do this,
    >
    > As always thanks.
    >
    >
    > For Each Cell In Selection
    > On Error Resume Next
    > If Cell.Interior.ColorIndex = 36 Then
    > If Cell = ISNUMBER then
    > End if
    >
    >
    > End If
    >
    > Next Cell
    >
    >
    > --
    > Ctech
    > ------------------------------------------------------------------------
    > Ctech's Profile:
    > http://www.excelforum.com/member.php...o&userid=27745
    > View this thread: http://www.excelforum.com/showthread...hreadid=500327
    >




  4. #4
    Niek Otten
    Guest

    Re: Sum all cells with interior color...

    http://cpearson.com/excel/colors.htm

    --
    Kind regards,

    Niek Otten


    "Ctech" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi
    >
    > I'm trying to make a macro which will sum all the cells which have a
    > special interior color.
    >
    > However I don't know how to sum these cells. I will also need to check
    > if the Cell contains a number (ISNUMBER).
    >
    > Do anyone know how I can do this,
    >
    > As always thanks.
    >
    >
    > For Each Cell In Selection
    > On Error Resume Next
    > If Cell.Interior.ColorIndex = 36 Then
    > If Cell = ISNUMBER then
    > End if
    >
    >
    > End If
    >
    > Next Cell
    >
    >
    > --
    > Ctech
    > ------------------------------------------------------------------------
    > Ctech's Profile:
    > http://www.excelforum.com/member.php...o&userid=27745
    > View this thread: http://www.excelforum.com/showthread...hreadid=500327
    >




  5. #5
    Yngve
    Guest

    Re: Sum all cells with interior color...

    Hi Ctect

    this should work
    Sub b()

    Dim p As Double
    p = 0
    For Each cell In Selection
    On Error Resume Next
    If cell.Interior.ColorIndex = 36 Then
    If IsNumeric(cell) Then
    p = p + cell.Value
    End If


    End If


    Next cell

    end sub

    Regards Yngve


+ 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