ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   counting formatted cells in vba (https://www.excelbanter.com/excel-programming/296174-counting-formatted-cells-vba.html)

Simon Lloyd[_399_]

counting formatted cells in vba
 
Can anyone help with this? i am trying to count all cells in one colum
formatted a certain colour, here is what i have...it counts all th
cells until the date i have given it and returns that figure but is no
singling out the certain coloured ones....hope you can help!

Sub colorcount()
'
' colorcount Macro
' Macro recorded 22/04/04 by simon
'
' Keyboard Shortcut: Ctrl+Shift+k
Dim ccount As Integer
Range("a9").Select
Do Until ActiveCell = "31/12/2004"
ActiveCell.Offset(1, 0).Select
Select Case ActiveCell.Offset(0, 0).FormatConditions.Count
Case Is = ColorIndex = 38
ccount = ccount + 1
End Select
Loop
MsgBox "There Are " & ccount & " Holiday Clashes"


End Sub

Simon

--
Message posted from http://www.ExcelForum.com


Dave Peterson[_3_]

counting formatted cells in vba
 
Take a look at Chip Pearson's site:
http://www.cpearson.com/excel/CFColors.htm

He has some code there that'll do what you want.

But if I were the developer of the workbook, then I'd know what those
conditional formatting formulas/rules were. I'd try to use those same rules in
code.

To me, it's a lot simpler.



"Simon Lloyd <" wrote:

Can anyone help with this? i am trying to count all cells in one column
formatted a certain colour, here is what i have...it counts all the
cells until the date i have given it and returns that figure but is not
singling out the certain coloured ones....hope you can help!

Sub colorcount()
'
' colorcount Macro
' Macro recorded 22/04/04 by simon
'
' Keyboard Shortcut: Ctrl+Shift+k
Dim ccount As Integer
Range("a9").Select
Do Until ActiveCell = "31/12/2004"
ActiveCell.Offset(1, 0).Select
Select Case ActiveCell.Offset(0, 0).FormatConditions.Count
Case Is = ColorIndex = 38
ccount = ccount + 1
End Select
Loop
MsgBox "There Are " & ccount & " Holiday Clashes"

End Sub

Simon.

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson



All times are GMT +1. The time now is 08:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com