count number of cell that contain red text

 

Step 1: Open the VBA Editor

  1. Press Alt + F11 to open the VBA editor.
  2. 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

  1. Close the VBA editor (Alt + Q).
  2. Go back to your worksheet.
  3. In a blank cell, enter the formula:
=CountRedText(A10:A190)


Comments

Popular posts from this blog

Basic Web Design with HTML and CSS

Project Web Design Assignment