count the number of times a specific word appears in a range of cells

Rossjp

Board Regular
Joined
Nov 14, 2005
Messages
67
In a range of cells, a1:f1 specific words may be entered. I want a siple count of the number of times a specific word appears in this range at cell G1. Any assistance will be greatly appreciated.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
try


Book1
ABCDEFGH
1JohnJohn JohnJohn3
Sheet15
Cell Formulas
RangeFormula
H1=SUMPRODUCT((LEN(A1:F1)-LEN(SUBSTITUTE(A1:F1,$G$1,"")))/LEN($G$1))
 
Last edited:
Upvote 0
Code:
Option Explicit


Sub CountWord()
    Dim x As Long
    x = 0
    Dim rng As Range
    Dim c As Range
    Set rng = Range("A1:F1")
    Dim crit As String
    crit = InputBox("What word to search")
    For Each c In rng
        If InStr(c, crit) > 0 Then
            x = x + 1
        End If
    Next c
    Range("G1") = x


End Sub
 
Upvote 0

Forum statistics

Threads
1,215,545
Messages
6,125,455
Members
449,228
Latest member
moaz_cma

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top