Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Search text & record number of times it appears

Dear All,
I need to search & record the number times the text appears in a
paragraph. I need to use the Find function (in my scenario) Any help
out there?

Thank you.

Regards,
Julian

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Search text & record number of times it appears

Where is your paragraph stored? If it is all in one cell eg A1 then
enter the text you are serching for in B1 and then in any cell enter the
formula:
=(LEN(A1)-LEN(SUBSTITUTE(A1,B1,"")))/LEN(B1)

Hope this helps
Rowan

wrote:
Dear All,
I need to search & record the number times the text appears in a
paragraph. I need to use the Find function (in my scenario) Any help
out there?

Thank you.

Regards,
Julian

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Search text & record number of times it appears

Hi, the text may appear in several cells in the sheet. That is why I
need to use the FIND function.

Regards,
Julian

Rowan wrote:
Where is your paragraph stored? If it is all in one cell eg A1 then
enter the text you are serching for in B1 and then in any cell enter the
formula:
=(LEN(A1)-LEN(SUBSTITUTE(A1,B1,"")))/LEN(B1)

Hope this helps
Rowan

wrote:
Dear All,
I need to search & record the number times the text appears in a
paragraph. I need to use the Find function (in my scenario) Any help
out there?

Thank you.

Regards,
Julian


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Search text & record number of times it appears

Maybe like this but it will only find the number of cells that contain
the text, so if you have one cell that contains the text 5 times that
will only be counted as 1.

Sub FindAll()
Dim Found As Integer
Dim c As Range
Dim firstAddress As String
Const findText As String = "dog" 'text to find

With Worksheets(1).Range("a1:f500") 'set range and sheet
Set c = .Find(findText, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Found = Found + 1
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
MsgBox "Found " & Found & " instances of " & findText
End Sub

Regards
Rowan

wrote:
Hi, the text may appear in several cells in the sheet. That is why I
need to use the FIND function.

Regards,
Julian

Rowan wrote:

Where is your paragraph stored? If it is all in one cell eg A1 then
enter the text you are serching for in B1 and then in any cell enter the
formula:
=(LEN(A1)-LEN(SUBSTITUTE(A1,B1,"")))/LEN(B1)

Hope this helps
Rowan

wrote:

Dear All,
I need to search & record the number times the text appears in a
paragraph. I need to use the Find function (in my scenario) Any help
out there?

Thank you.

Regards,
Julian



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Search text & record number of times it appears

That was quick. Worked like a charm. Thanks a million

regards,
Julian



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Search text & record number of times it appears

You're welcome.

wrote:
That was quick. Worked like a charm. Thanks a million

regards,
Julian

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Search text & record number of times it appears

Here's a shorter version


Sub CountCells()
Dim findText as String, found as Long
findText = "dog"
Found = application.Countif(worksheets(1).Range("A1:Z26"), _
"*" & findText & "*")
MsgBox "Found " & Found & " instances of " & findText
End sub

--
Regards,
Tom Ogilvy

wrote in message
oups.com...
That was quick. Worked like a charm. Thanks a million

regards,
Julian



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count number times text appears in string nc Excel Discussion (Misc queries) 0 May 5th 10 02:41 PM
Count the number of times specific text appears in a column Nannie Excel Worksheet Functions 5 August 27th 08 07:09 PM
Counting the times a number appears Jennifer B[_2_] Excel Discussion (Misc queries) 2 July 17th 08 11:54 PM
count number of times text appears MMcQ Excel Discussion (Misc queries) 3 February 9th 07 07:33 PM
How do I count the number of times a value appears? Christine Excel Worksheet Functions 2 February 8th 07 09:38 PM


All times are GMT +1. The time now is 05:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"