If cell contain any part of text

NMaxis

New Member
Joined
Jul 14, 2016
Messages
19
Hello,

Currently on my workbook I have a formula like:
=SUMPRODUCT(COUNTIF(E2:E495,{"San Francisco CA";"Santa Rosa CA";"Los Angles CA";"Los Angeles";"Long Beach CA";"Long Beach"}))
to add to a total when this specific cites are listed. However what I want to do is to mark them when any variation of those cites are in that cell regardless of the full exit the cell.

For example:
598-Santa Rosa
Santa Rosa health center
Santa Rosa United

Would all count as well as just "Santa Rosa CA"

ANY help would be greatly appreciated, thank you.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi,

Not sure to fully understand your constraints ...

Could you test following ...

Code:
[SIZE=2][FONT=inherit]=[/FONT][URL="https://exceljet.net/excel-functions/excel-sumproduct-function"][FONT=inherit]SUMPRODUCT[/FONT][/URL][FONT=inherit](([/FONT][FONT=inherit]--[/FONT][URL="https://exceljet.net/excel-functions/excel-exact-function"][FONT=inherit]EXACT[/FONT][/URL][FONT=inherit]("*"&[/FONT][/SIZE][COLOR=#333333]"Santa Rosa CA"&"*"[/COLOR][SIZE=2][FONT=inherit],[/FONT][/SIZE][COLOR=#333333]E2:E495[/COLOR][SIZE=2][FONT=inherit])))[/FONT][/SIZE]

Hope this will help
 
Upvote 0
I notice that none of your examples have "CA" in them, so you may need to remove that part from the formula James recommended, i.e.
Code:
[SIZE=2][FONT=inherit]=[/FONT][URL="https://www.mrexcel.com/forum/redirect-to/?redirect=https%3A%2F%2Fexceljet.net%2Fexcel-functions%2Fexcel-sumproduct-function"][FONT=inherit]SUMPRODUCT[/FONT][/URL][FONT=inherit](([/FONT][FONT=inherit]--[/FONT][URL="https://www.mrexcel.com/forum/redirect-to/?redirect=https%3A%2F%2Fexceljet.net%2Fexcel-functions%2Fexcel-exact-function"][FONT=inherit]EXACT[/FONT][/URL][FONT=inherit]("*"&[/FONT][/SIZE][COLOR=#333333]"Santa Rosa"&"*"[/COLOR][SIZE=2],[/SIZE][COLOR=#333333]E2:E495[/COLOR][SIZE=2])))[/SIZE]
 
Upvote 0
I'm afraid that didn't work, it returned a result of zero for all three examples. Essentially I'm working a spreadsheet where for example there are many different names of the locations with a city (such as Santa Rosa) and I want to count each and every loaction in the column that features the cities name. But for every city in California not just Santa rosa.

For example all in one column.

Santa Rosa PA
Santa Rosa Dog park
Los Angeles airport
San Francisco museum
St. Louis library
Buffalo, NY transit.

I want the formula to pick up on "Santa Rosa", "Los Angeles", and San Francisco". And mark in the new column (so "3" would so up). Essentially if an cell contains any part of the listed city for it to count as a mark.
 
Upvote 0
Hello,


Say the cell to be tested in cell A2 ... and your 6 reference items are located in D1:D6

you could test the following Array Formula:

Code:
=IFERROR(MATCH(TRUE,ISNUMBER(SEARCH($D$1:$D$6, A2)),0),"")
[/COLOR][COLOR=#333333]

Hope this will help
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top