Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Macro for finding number of times a word repeats in a cell

Hi,
I am a very amateur excel user. Can you help me with a macro to find a
particular word/phrase from the spreadsheet and give an output on the number
of times a word/phrase is repeated in a different cell
E.g If Cell B5 has the word "This spreadsheet contains information on basic
excel topics and advanced excel topics". A macro should find that the phrase
"excel topics" had been repeated twice in cell B5 of the spreadsheet. This
number should be printed in cell C5.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Macro for finding number of times a word repeats in a cell

Hi

Look in Help for the CountIf function

In a cell you use this
=COUNTIF(A1:A33,"ron")

You can use it in VBA like this

MsgBox Application.WorksheetFunction.CountIf(Range("A1:A3 3"), "ron")




--
Regards Ron de Bruin
http://www.rondebruin.nl



"Vineeth" wrote in message ...
Hi,
I am a very amateur excel user. Can you help me with a macro to find a
particular word/phrase from the spreadsheet and give an output on the number
of times a word/phrase is repeated in a different cell
E.g If Cell B5 has the word "This spreadsheet contains information on basic
excel topics and advanced excel topics". A macro should find that the phrase
"excel topics" had been repeated twice in cell B5 of the spreadsheet. This
number should be printed in cell C5.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Macro for finding number of times a word repeats in a cell

=(LEN(B5)-LEN(SUBSTITUTE(LOWER(B5),"excel topics","")))/LEN("excel topics")

likewise in VBA

Dim s as String, s1 as String, cnt as Long
s = lcase("excel topics")
s1 = lcase(Range("B5").Value)
cnt = (len(s1)-len(replace(s1,s,"")))/len(s)
Range("C5").Value = cnt

--
Regards,
Tom Ogilvy


"Vineeth" wrote:

Hi,
I am a very amateur excel user. Can you help me with a macro to find a
particular word/phrase from the spreadsheet and give an output on the number
of times a word/phrase is repeated in a different cell
E.g If Cell B5 has the word "This spreadsheet contains information on basic
excel topics and advanced excel topics". A macro should find that the phrase
"excel topics" had been repeated twice in cell B5 of the spreadsheet. This
number should be printed in cell C5.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Macro for finding number of times a word repeats in a cell

Oops, see Tom's reply

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Ron de Bruin" wrote in message ...
Hi

Look in Help for the CountIf function

In a cell you use this
=COUNTIF(A1:A33,"ron")

You can use it in VBA like this

MsgBox Application.WorksheetFunction.CountIf(Range("A1:A3 3"), "ron")




--
Regards Ron de Bruin
http://www.rondebruin.nl



"Vineeth" wrote in message ...
Hi,
I am a very amateur excel user. Can you help me with a macro to find a
particular word/phrase from the spreadsheet and give an output on the number
of times a word/phrase is repeated in a different cell
E.g If Cell B5 has the word "This spreadsheet contains information on basic
excel topics and advanced excel topics". A macro should find that the phrase
"excel topics" had been repeated twice in cell B5 of the spreadsheet. This
number should be printed in cell C5.





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
Counting number of times a specific word appears in a single cell Ken Curtis Excel Discussion (Misc queries) 19 June 16th 09 05:34 AM
Finding the number of times a word is used in a range of cells Ray Hill Excel Worksheet Functions 8 January 15th 09 07:21 PM
Finding Minimum but if same number repeats in the range, then find MIK Excel Discussion (Misc queries) 1 January 9th 09 03:13 AM
finding a number and the number of times it occurs luposlipophobia Excel Discussion (Misc queries) 3 June 22nd 06 03:51 AM
How can I count the number of times a letter repeats in a string? Wiley Excel Worksheet Functions 3 May 11th 06 06:53 PM


All times are GMT +1. The time now is 11:20 PM.

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

About Us

"It's about Microsoft Excel"