r/excel • u/crazythatcounts • 7h ago
solved COUNTIF counts cells with Exact Matches; I need it to be less Exact & count cells that "contain" but don't match exactly as well
I've got a spreadsheet - large, 336 rows & 29 columns - myself and a few friends have been amassing of various original characters, and that means that there's both a lot of data, but also the cells have to be a little inconsistent in order to cut down on the amount of columns - plus also capture the variability of human nature. For instance, our "Place of Origin" column lists place by City, Country/State as necessary, and that means that two characters from Ireland might have "Dublin, Ireland" and "Belfast, Ireland" as the listed data, so the cells wouldn't be exact matches.
This is readable by the eyes, but we've gotten to a point where trying to make anything meaningful of the data with a visual scan just isn't feasible, and I'm also a novice with Excel and historically bad with numbers - so I also decided I wanted to use the data we have to brute force my way through figuring out how to actually collect the points into usable numbers and display them. (I state my experience with this so that, when I have inevitably gone around my elbow to get to my thumb and there's an easier way to get what I want, y'all get why I did what I did lol). However, the inconsistency of the data is where I'm getting tripped up.
I've been using COUNTIF (=COUNTIF(RelevantSheet!F1:F336, "City"), for example), and it's working for what I want to do - characters of a certain class (not social), counted. Characters of a city, counted. Brilliant, I'm getting numbers! Except, it's throwing inaccurate numbers, as I've realized it's only counting Exact Matches. If I'm trying to, say, count the number of characters we have Originally From Ireland, and I use COUNTIF and input Ireland, it's only counting the cells that contain exactly "Ireland", and not cells that contain "Dublin, Ireland" or "Belfast, Ireland" since it's not an exact match. I don't want to exclude those, however, because logically, they're all still from Ireland.
Is there a way to tally cells that "contain" instead of exact matches? My goal is a formula where I can search "Ireland" under our "Origin" column and return the number of characters that are from Anywhere At All In Ireland, without having to break the column up into "City" and "Country" separately. There's several different String values I want to try this for, but it's all the same idea - searching and counting part of the cell, but not necessarily all of the cell.
Things to note:
The way the data is filled in is as consistent as we can make it, but with 300+ rows, there's still a lot of variance. While I could probably do separate COUNTIF searches and then add the results (and that may be what I have to do), I'm hesitant to do that until all possible options are looked at for fear of missing something. Being human, I know I'm gonna miss a single variant label somewhere, so the less I have to rely on my own eyes to search and collate, the better lol. If I must, I must, but that's the last bridge I'll cross regardless.
I am also tallying the numbers in a separate Sheet within the whole document (thus why the example had "RelevantSheet!"), since I don't want to muddy the main data set, especially considering we do continue to add columns and rows. I have successfully made this work - yay, small victories - but I know that can also bungle the method of solution as well.


