+ Reply to Thread
Results 1 to 6 of 6

How to search word in another sheet and get the count of the rows with that word?

  1. #1
    Registered User
    Join Date
    08-17-2015
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    1

    How to search word in another sheet and get the count of the rows with that word?

    I have a sheet with unique numbers(BUN(business unit number) in this case). I want to search with a word or words in another sheet (Sheet2) where same BUN numbers appear in multiple rows and type of work done in the beside coulumns. in the Sheet 1 I want to put the number of rows( where those particular words appear ) in a column.

    For example I want to search word 'maintenance' in the 'job description' in sheet 2 for a particual 'BUN' which may have multiple rows and return the number of those rows where this word is found and put it in the cell beside that 'BUN' in Sheet 1.

    Is this possible? How can I accomplish this task as 'Job description' column in Sheet 2 has sentences in it.

    Sorry If i confused you but you will understand it when you look at the attached file.
    Attached Files Attached Files

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: How to search word in another sheet and get the count of the rows with that word?

    Using your posted workbook...
    This formula returns the count of Sheet2, Col_B rows that contain either "maintenance" or "PM"
    Please Login or Register  to view this content.
    and this formula returns the count for rows containing either "fault" or "emergency repair"
    Please Login or Register  to view this content.
    The asterisks (*) in those formulas are wildcards that represent zero or more characters.

    edited to include these alternatives:
    If some cells may contain both values, but you only want them counted once...
    This array formula, completed by holding down CTRL and SHIFT when you press ENTER (instead of just pressing ENTER) handles that
    Please Login or Register  to view this content.
    Also, some cells contain "red herrings"...they contain matching text that is not valid.
    Example:
    "Equipment" contains "pm"

    To minimize formula complexity, you might want to consider a VBA approach.

    Is that something you can work with?
    Last edited by Ron Coderre; 08-17-2015 at 10:25 AM.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: How to search word in another sheet and get the count of the rows with that word?

    @Ron

    I think you missed the BUN criteria in the formula.

    Would it be like this then?

    On Sheet1
    In B2

    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: How to search word in another sheet and get the count of the rows with that word?

    I DID sktneer...Thanks for catching that.

    I also noticed in the data that some cells contain values that match the criteria but are not what we want to count.
    Example:
    "equipment" contains "pm"
    I edited my post to suggest a VBA approach (which could use Regular Expressions) to narrow the criteria for matching cells.

  5. #5
    Forum Contributor
    Join Date
    08-07-2015
    Location
    AB, Canada
    MS-Off Ver
    Excel 2013 x64
    Posts
    132

    Re: How to search word in another sheet and get the count of the rows with that word?

    Ron,

    Is it possible to use a similar formula as an AND statement instead of an OR? (count the number of cells that contains "fault" AND "maintenance" in the same line?)


    Never mind, I figured it out! Thanks for the solution.
    Please Login or Register  to view this content.
    Last edited by ThirdFret; 08-17-2015 at 10:44 AM. Reason: Solved

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: How to search word in another sheet and get the count of the rows with that word?

    Actually, since there can be some double-counting, you might want to try This ARRAY FORMULAS, completed by holding down CTRL and SHIFT when you press ENTER (instead of just pressing ENTER)
    ...which include the test for matching BUN and avoids the double counting.
    Please Login or Register  to view this content.
    Does that help?

+ 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. Replies: 2
    Last Post: 04-29-2014, 10:06 AM
  2. Need help to search a word in the sheet and group the respective rows with sum
    By siri_tvrs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-06-2013, 05:21 AM
  3. Replies: 2
    Last Post: 08-05-2013, 04:45 PM
  4. Search document for rows containing a specific word, cut/paste into new sheet
    By mea02300 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-09-2013, 08:44 AM
  5. Replies: 1
    Last Post: 01-25-2011, 10:50 PM
  6. Replies: 0
    Last Post: 07-15-2009, 01:17 PM
  7. [SOLVED] search for a specific word and copy the word and the preceeding words until a comma
    By DHANANJAY in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-31-2005, 09:10 AM

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