+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    10-07-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    1

    Search the number of times 2 corresponding values appear

    This is a hard one for me to explain, so I have attached a sample document to better demonstrate this.

    I have found out how to search the number of times appears in a column.

    {=SUM(IF(ISNUMBER(SEARCH(A15,A1:A6)),1,0))}

    What I would like to do is to search the number of times two corresponding values appear within the same row.

    In the attached example, I have two columns

    COLUMN A(NAME)_________________B1(LETTERS)
    Bob________________________________abc
    Mary_______________________________abc
    Fred_______________________________abc
    Bob________________________________def
    Mary_______________________________def
    Fred_______________________________def



    I would like to know the number of times BOB and abc appear in the same row.

    In reality, the data appears more like this;

    xxxBOBzzz
    yyyBOBaaa

    so it really needs to be a search string, rather than having the cells being "equal to" the value 'BOB'

    I have only read access to the database I am extracting data from, so cannot re-jig the database, but I need to do calculations on the data.

    Just to clarify what I'm asking... how do I count the number of times 'BOB' and 'abc' appear in the same row?

    Any help would be greatly appreciated.
    Attached Files Attached Files

  2. #2
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Search the number of times 2 corresponding values appear

    First, just to clarify...

    Code:
    {=SUM(IF(ISNUMBER(SEARCH(A15,A1:A6)),1,0))}
    can be done using COUNTIF with Wildcard (ie avoid Array)

    Code:
    =COUNTIF(A1:A6,"*"&A15&"*")
    Second, to answer your question, based on your sample file and setup

    Code:
    B8:
    =SUMPRODUCT(--ISNUMBER(SEARCH(LEFT($A8,FIND("-",$A8&"-")-1),$A$1:$A$6)),--ISNUMBER(SEARCH(REPLACE($A8,1,FIND("-",$A8&"-"),""),$B$1:$B$6)))
    copied down to B13
    Though not requiring CTRL + SHIFT + ENTER the above function (SUMPRODUCT) is processed by XL along similar lines and has similar effect in terms of efficiency.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0