1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| Option Explicit
Public Function COUNTFORMAT(ByVal rgeValues As Range, _ ByVal rgeExampleCell As Range, _ Optional ByVal bBackGround As Boolean = True, _ Optional ByVal bText As Boolean = False) As Integer
Dim objCell As Range Dim itotalcells As Integer
Call Application.Volatile(True)
itotalcells = 0 If bBackGround = True Then For Each objCell In rgeValues If objCell.Interior.ColorIndex = rgeExampleCell.Interior.ColorIndex Then itotalcells = itotalcells + 1 End If Next objCell End If
If bText = True Then For Each objCell In rgeValues If objCell.Font.ColorIndex = rgeExampleCell.Font.ColorIndex Then itotalcells = itotalcells + 1 End If Next objCell End If COUNTFORMAT = itotalcells End Function
|