+ Reply to Thread
Results 1 to 6 of 6

Count occurrences of a text string in a range of cells

  1. #1
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    326

    Count occurrences of a text string in a range of cells

    Hi,

    What is the code to count the number of occurrences of a text string in a row? For example, how many times does "Item#" appear in row 10?

    I already have the range to search, so logic something like:

    Please Login or Register  to view this content.
    Thanks,

    Lawrence
    Last edited by skysurfer; 05-30-2012 at 03:57 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Count occurrences of a text string in a range of cells

    Hi,.

    Assuming 'Item#' is the only text in a particular cell on a row and not embedded within other text in a cell, e.g. 'This is Item#' then a simple

    =COUNTIFS(A1:Z1,"Item#") function will do.

    Otherwise programatically assuming firstrow, firstcolumn, lastrow, lastcolumn are numeric integers.

    Please Login or Register  to view this content.

    Rgds
    Last edited by Richard Buttrey; 05-30-2012 at 03:59 PM.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Count occurrences of a text string in a range of cells

    Hi you can use builtin function in vba
    Please Login or Register  to view this content.
    this will count quantity of "a" strings in row 10
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  4. #4
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Count occurrences of a text string in a range of cells

    I think Richard, means... =COUNTIF(A1:Z1,"Item#")

    No, =COUNTIFS(A1:Z1,"Item#")
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  5. #5
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    326

    Re: Count occurrences of a text string in a range of cells

    Sweet!

    Always the simple stuff tripping me up. Thank you!!!

    Lawrence

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Count occurrences of a text string in a range of cells

    [QUOTE=Fotis1991;2806805]I think Richard, means... =COUNTIF(A1:Z1,"Item#")

    Indeed - well spotted.

    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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