![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 1
|
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 |
|
Board Regular
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
|
__________________
Veni, Vidi, Velcro - I came, I saw, I stuck around Taxation WITH representation ain't so hot either |
|
|
|
|
|
#3 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
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 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|