Counting highlighted cells?

  • Thread starter Josh - Westfield Australia
  • Start date
J

Josh - Westfield Australia

Is there a way to count cells in a column which have been highlighted or text
that has been italicised??. As i have a column full of dates, and when
something is completed the suggested date is changed to the actual date,
highlighted and italicised. I need to keep a count on the completed dates.
 
B

Bob Phillips

There is a solution at
http://www.xldynamic.com/source/xld.ColourCounter.html that shows how to
count coloured text/cells. Frank Kabel wrote a textstyle function that we
used in this concept, which is given below

'---------------------------------------------------------------------------
Function TextStyle(rng As Range, _
Optional iStyle As Integer = 1) As Variant
'---------------------------------------------------------------------------
Dim cell As Range, row As Range
Dim i As Long, j As Long
Dim aryStyle As Variant

Application.Volatile
If rng.Areas.Count > 1 Then
TextStyle = CVErr(xlErrValue)
Exit Function
End If

If rng.Cells.Count = 1 Then
Select Case iStyle
Case 1:
aryStyle = (rng.Font.Underline <> xlUnderlineStyleNone)
Case 2:
aryStyle = rng.Font.Bold
Case 3:
aryStyle = rng.Font.Italic
End Select

Else
aryStyle = rng.Value
i = 0

For Each row In rng.Rows
i = i + 1
j = 0

For Each cell In row.Cells
j = j + 1
Select Case iStyle
Case 1:
aryStyle(i, j) = CBool(cell.Font.Underline <>
xlUnderlineStyleNone)
Case 2:
aryStyle(i, j) = CBool(cell.Font.Bold = True)
Case 3:
aryStyle(i, j) = CBool(cell.Font.Italic)
End Select
Next cell
Next row
End If

TextStyle = aryStyle

End Function

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Josh - Westfield Australia" <Josh - Westfield
[email protected]> wrote in message
news:[email protected]...
 
Top