ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Count multiple specific terms (https://www.excelbanter.com/excel-worksheet-functions/450152-count-multiple-specific-terms.html)

masking

Count multiple specific terms
 
Hi,

I am looking to run a count (or similar) function to find cells that contain two words that are not immediately following.

E.g.
Cell B2: "this cell contains text"
Cell B3: "this cell contains no text"
Cell B4: "this table contains no text"

Count (how many times "no" and "cell" appear in the same cell). =1

Can anybody advise such a function?

Claus Busch

Count multiple specific terms
 
Hi,

Am Wed, 11 Jun 2014 13:28:31 +0100 schrieb masking:

Cell B2: "this cell contains text"
Cell B3: "this cell contains no text"
Cell B4: "this table contains no text"


try following UDF:

Function myWords(myRng As Range, ParamArray searchW()) As Long
Dim rngC As Range
Dim i As Long, counter As Long

For Each rngC In myRng
counter = 0
For i = LBound(searchW) To UBound(searchW)
If InStr(rngC, searchW(i)) Then
counter = counter + 1
End If
Next
If counter = UBound(searchW) + 1 Then
myWords = myWords + 1
End If
Next
End Function

and call the function into the sheet with:
=myWords(B1:B100,"cell","no")


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional


All times are GMT +1. The time now is 05:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com