VBA Code to Count Cells with Specific Text in Excel

This code counts the number of cells in the selected range that contain specific text.

VBA Code:

Sub CountCellsSpecificText()
    Dim searchText As String
    Dim count As Long
    searchText = "Text"
    count = Application.WorksheetFunction.CountIf(Selection, searchText)
    MsgBox "Count: " & count
End Sub

Check All VBA Codes

Join Our Telegram Group techguruplus telegram group Join Our WhatsApp Group techguruplus whatsapp group

Leave a Comment