+ Reply to Thread
Results 1 to 9 of 9

Searching two columns for one word

Hybrid View

  1. #1
    Registered User
    Join Date
    04-30-2012
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    88

    Searching two columns for one word

    Hello

    I need to look for a single word in two columns A and B which contain multiple words and then return that word with the totals of columns C and D. I've attached a sample book which should hopefully make it clearer.

    Thanks in advance for help
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    04-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    547

    Re: Searching two columns for one word

    try in B14

    =SUM(IF((NOT(ISERROR(SEARCH($A14,$A$2:$A$5))))+(NOT(ISERROR(SEARCH($A14,$B$2:$B$5)))),C$2:C$5))
    copy across and down.
    Like a post? Click the star below it!

  3. #3
    Registered User
    Join Date
    04-30-2012
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    88

    Re: Searching two columns for one word

    Hi

    Thanks for the reply, unfortunately it's returned 0 when I enter it and also when I copy it down...

  4. #4
    Valued Forum Contributor
    Join Date
    04-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    547

    Re: Searching two columns for one word

    Quote Originally Posted by Steve_123 View Post
    Hi

    Thanks for the reply, unfortunately it's returned 0 when I enter it and also when I copy it down...
    It's an array formula and needs to be confirmed with Ctrl-Shift-Enter. Sorry, forgot to mention that.

    Nevermind, though, Pete's suggestion is more elegant.

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,408

    Re: Searching two columns for one word

    This will work for your sample data:

    =SUMIF($A$2:$A$5,"*"&$A14&"*",C$2:C$5)+SUMIF($B$2:$B$5,"*"&$A14&"*",C$2:C$5)

    which can be copied across and down.

    However, it will give misleading results if your keyword occurs in both columns for a particular row.

    Hope this helps.

    Pete

  6. #6
    Registered User
    Join Date
    04-30-2012
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    88

    Re: Searching two columns for one word

    Thanks for your responses guys. Sorry to be a pain in the but for my main document it will have sometimes have the same results in both fields. Any ideas on how to get round that?

    Also, I tried Ctrl+Shift+Enter and it's not working!

    Cheers again

    Steve

  7. #7
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,408

    Re: Searching two columns for one word

    This array* formula seems to work:

    =SUM(IF((ISNUMBER(SEARCH($A14,$A$2:$A$5)))+(ISNUMBER(SEARCH($A14,$B$2:$B$5))),C$2:C$5))

    *An array formula needs to be committed using the key combination of <Ctrl><Shift><Enter> (CSE) instead of the usual <Enter>. If you do this correctly then Excel will wrap curly braces around the formula when viewed in the formula bar, but you should not type these yourself. If you need to amend the formula then you will have to use CSE again.

    Hope this helps.

    Pete

  8. #8
    Valued Forum Contributor
    Join Date
    04-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    547

    Re: Searching two columns for one word

    Here is the array formula applied to your file.

    I added the text ".Net" to cell B3 to show that duplicate occurrences don't matter with this formula.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    04-30-2012
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    88

    Re: Searching two columns for one word

    Beautiful! Cheers both of you for your help and patience!

+ 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