• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Formula to count occurrence of two words being in one row|General Excel Questions & Answers|Excel Forum|My Online Training Hub

You are here: Home / Formula to count occurrence of two words being in one row|General Excel Questions & Answers|Excel Forum|My Online Training Hub

vba course banner

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumGeneral Excel Questions & Answe…Formula to count occurrence of two …
sp_PrintTopic sp_TopicIcon
Formula to count occurrence of two words being in one row
Avatar
Matt K

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
February 1, 2022
sp_UserOfflineSmall Offline
1
February 1, 2022 - 4:56 am
sp_Permalink sp_Print

I am looking for a formula that can count specific words appearing together in a row. I've tried countifs, but it doesn't seem to work. For example, I want the formula to return the number of occurrences that the word "house" appears in the same row as the word in the table.

 

Data (rows in excel)

I have a house.

We don't have a big house.

The house is big.

We have a house that is big.

The big house is expensive.

 

Fixed word for formula

house

 

Table

big: should return 4

expensive: should return 1

have: should return 3

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1529
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
February 1, 2022 - 3:39 pm
sp_Permalink sp_Print

Hi Matt,

If your data is in A1:A5 and you have the words to search for (e.g. big and house) in B1 and B2 then this works

=COUNT(SEARCH(B1,$A$1:$A$5)*SEARCH(B2,$A$1:$A$5))

Modify the cell/table references as needed - see attached workbook.

Note that searching for strings like big will return a found result when it comes across a word like bigger so you may need to adjust what you are searching for by including spaces before or after the word e.g. "big "

Regards

Phil

Avatar
Matt K

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
February 1, 2022
sp_UserOfflineSmall Offline
3
February 1, 2022 - 7:33 pm
sp_Permalink sp_Print

Hi Phil, thank you for your quick and useful answer. I should have clarified that the text is not in one cell, but each word separately (please see below an example). Therefore the search area isn't only one column, but an area. The search criteria I'm looking for would look for a combination of words in the same row. If helpful, I'm happy to send you an excel sheet with more details.

A1       B1        C1       D1

I        Have       a        house

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1529
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
February 1, 2022 - 8:47 pm
sp_Permalink sp_Print

Hi Matt,

Yes a workbook with actual data is always better so that mistakes aren't made when recreating data from a written description of it.

Also, please be specific about what word combinations are being searched for and provide examples of results you expect.  For example will you always be searching for the same 2 words across all rows?  Or will there be different combinations of words looked for in different rows?

regards

Phil

Avatar
Matt K

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
February 1, 2022
sp_UserOfflineSmall Offline
5
February 1, 2022 - 9:36 pm
sp_Permalink sp_Print

Hi Phil,

Please find attached my file. I've tried to make it as clear as possible, also what the formula should return. As mentioned, I'm interested in getting the word combinations on any given row.

Thank you

Matthias

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 648
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
6
February 2, 2022 - 12:00 am
sp_Permalink sp_Print

The attachment didn't make it.

 

Also, which version of Excel are you using?

Avatar
Matt K

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
February 1, 2022
sp_UserOfflineSmall Offline
7
February 2, 2022 - 12:02 am
sp_Permalink sp_Print

Hi,rnI've figured out that I can create cells that combine the text into one, and use your formula - thank you. An additional query I have is whether your formula can be used with an IF function. In my attached file, only to consider those that have the number 1 in column I. rnMany thanksMatthias

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 648
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
8
February 2, 2022 - 9:00 pm
sp_Permalink sp_Print

You could use a small tweak:

=COUNT(SEARCH($J$1,$H$2:$H$7)*SEARCH(M5,$H$2:$H$7)/($I$2:$I$7=1))

Note: may need array entering depending on your version of Excel.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Andrew Wilkie, Malcolm Sawyer
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 216
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Melanie Ford
Isaac Felbah
Adele Glover
Hitesh Asrani
Rohan Abraham
Anthony van Riessen
Erlinda Eloriaga
Abisola Ogundele
MARTYN STERRY
Rahim Lakhani
Forum Stats:
Groups: 3
Forums: 24
Topics: 6355
Posts: 27792

 

Member Stats:
Guest Posters: 49
Members: 32324
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.