Count the number of times a text is in a column

easybpw

Active Member
Joined
Sep 30, 2003
Messages
437
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
Hello and thanks in advance for the help.

I have a sheet that has strings of text in column C. I need to count the number of times a specific word is in those strings. For example I could be looking for ALIBEN. That text will only be in one time in the each cell in column C but may only be in 25 of the 5000 cells I am looking at. This seems simple but I've been unable to come up with something that works.

Thanks!

Bill
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
As long as the word is not embedded as part of another word (CALIBEN), then something like this should work
=COUNTIF(C:C,"*ALIBEN*")

Is that something you can work with?
 
Upvote 0
Hello and thanks in advance for the help.

I have a sheet that has strings of text in column C. I need to count the number of times a specific word is in those strings. For example I could be looking for ALIBEN. That text will only be in one time in the each cell in column C but may only be in 25 of the 5000 cells I am looking at. This seems simple but I've been unable to come up with something that works.

Thanks!

Bill

Code:
Sub 25032013()

'globally declare variables
'
Dim myRange As Range
Dim myPattern As String
Dim myCell As Range
Dim a As Long
a = 0
'
'choose range of data to test
'
Set myRange = Range(Range("C1"), Range("C" & Rows.Count).End(xlUp))
'
'what to look for in each cell in the range (in this example, "ALIBEN" anywhere)
'
myPattern = "*ALIBEN*"
'
'turn off screen updating
'
Application.ScreenUpdating = False
'
'update status bar
'
Application.StatusBar = "Macro running, please wait...."
'
'begin routine
'
For Each myCell In myRange
    With myCell
      If (.Value Like myPattern) Then
         a = a + 1
      End If
    End With
Next
'
'turn on screen updating
'
Application.ScreenUpdating = True
'
'reset status bar
'
Application.StatusBar = False
MsgBox a
End Sub
 
Upvote 0
Yes. I tried this earlier but had an issue. ALIBEN is actually in another cell so I tried to do this: =COUNTIF(C:C,F5) but it didn't work. The way you put it works if I type what I'm looking for in the formula.
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,726
Members
448,987
Latest member
marion_davis

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