![]() |
![]() |
|
|||||||
| 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: Apr 2002
Posts: 14
|
I would like to count all cells in a range that contain an interior color regardless of color.
Thanks Paul Walton USAF |
|
|
|
|
|
#2 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
The solution to this is different based on conditional formatting or straight-up formatting.
This link is for straight-up formatting: http://www.mrexcel.com/board/viewtop...c=1585&forum=2 (Bottom post) _________________ Cheers, NateO [ This Message was edited by: NateO on 2002-05-01 09:50 ] |
|
|
|
|
|
#3 |
|
New Member
Join Date: Apr 2002
Posts: 14
|
Straight-Up Formatting
|
|
|
|
|
|
#4 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
The link above should be of serious use then. Post back w/ additional questions or concerns.
|
|
|
|
|
|
#5 |
|
New Member
Join Date: Apr 2002
Posts: 14
|
Works good for only 1 color. I need it to work for a cell that contains a any color in a range.
|
|
|
|
|
|
#6 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Try this:
Code:
Function CountByColor(InputRange As Range) Dim cl As Range, TempCount As Double Application.Volatile TempCount = 0 On Error Resume Next For Each cl In InputRange.Cells If cl.Interior.ColorIndex <> xlNone Then TempCount = TempCount + 1 Next cl On Error GoTo 0 Set cl = Nothing CountByColor = TempCount End Function Hope this helps. _________________ Cheers, NateO [ This Message was edited by: NateO on 2002-05-01 10:11 ] |
|
|
|
|
|
#7 |
|
New Member
Join Date: Apr 2002
Posts: 14
|
Thanks... Works as advertised
Paul Walton USAF |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|