+ Reply to Thread
Results 1 to 4 of 4

Program to count a text occurrence

  1. #1
    Registered User
    Join Date
    08-15-2016
    Location
    Victoria BC, Canada
    MS-Off Ver
    2010
    Posts
    5

    Program to count a text occurrence

    I am writing a program to count the number of times a word can be found on the active sheet, but with my current code Excel will crash each time it is executed. I think it has something to do with the loop I have built in but after some trouble shooting I am still having the same problem.

    Here is the code

    Please Login or Register  to view this content.
    Last edited by GDuffell; 08-24-2016 at 01:46 PM. Reason: Removed attachment due to privacy

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Program to count a text occurrence

    That .Find method you are trying to use looks like maybe Word syntax or something, not Excel. Replace your entire with statement with:
    Please Login or Register  to view this content.
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Program to count a text occurrence

    That loop is counting the number of cells that have the search term.

    You could use this insead of that do loop
    Please Login or Register  to view this content.
    I'm a bit confused by the contradictory prompt that you provide to your users:
    "NOTE: This macro will find a whole word only. If the text you typed is part of a larger string, it will also be found."

    You might want to remove the * from the second argument of CountIf, if the you want that the other way.
    Last edited by mikerickson; 08-24-2016 at 02:57 PM.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Registered User
    Join Date
    08-15-2016
    Location
    Victoria BC, Canada
    MS-Off Ver
    2010
    Posts
    5

    Re: Program to count a text occurrence

    Thank you mikerickson. That worked perfectly. Simplicity is always the best answer

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Count and show the occurrence of a text only if present
    By somoro77 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-25-2016, 11:27 PM
  2. [SOLVED] count and sum occurrence against a value
    By koshur in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-28-2015, 02:46 AM
  3. [SOLVED] Count number of days since last text occurrence
    By Verifyor in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-21-2014, 11:24 AM
  4. Need a formula to count occurrence of text and calculate a sum total
    By tgaito in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-30-2014, 01:55 PM
  5. [SOLVED] Count Occurrence Of Text Within Individual Cell And Cell Range
    By jhudson444 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-06-2013, 09:06 PM
  6. [SOLVED] Count Intervals Before Next Occurrence
    By jasonsarea in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-15-2012, 05:10 AM
  7. Replies: 4
    Last Post: 03-29-2012, 09:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1