count number of cell that contain red text
Step 1: Open the VBA Editor
- Press
Alt + F11
to open the VBA editor. - In the editor, go to
Insert > Module.
Step 2: Add the VBA Code
Paste the following code into the module:
Function CountRedText(rng As Range) As Long
Dim cell As Range
Dim count As Long
count = 0
For Each cell In rng
If cell.Font.Color = RGB(255, 0, 0) Then ' Check for red text
count = count + 1
End If
Next cell
CountRedText = count
End Function
Step 3: Use the Function in Excel
- Close the VBA editor (
Alt + Q
). - Go back to your worksheet.
- In a blank cell, enter the formula:
=CountRedText(A10:A190)
Comments
Post a Comment