There could be quite a simple solution to this, but I am trying to find the number of times a unique variant (i.e. non-duplicates) of a string appears in a column. However this string is only part of the text contained in a cell, and not the entire cell. To illustrate:

```
EuropeSpainMadrid
EuropeSpainBarcelona
AsiaChinaShanghai
AsiaJapanTokyo
EuropeEnglandLondon
EuropeSpainMadrid
```

I would like to find how many unique instances there are of a string that contains “EuropeSpain”. So using this example, I would find that a variant of “EuropeSpain” appears only twice (given that the second instance of “EuropeSpainMadrid” is a duplicate).

A solution to this is to use pivots to summarise the data and remove duplicated; however given that my underlying dataset changes often this would require manual adjustments and corrections. I would therefore like to avoid adding any intermediate steps (i.e. PivotTables, other data sets etc) between my data and the counts.

**UPDATE:** I now understand to use wildcards to solve the first part of my question (counting the occurrences of “EuropeSpain”), however I am not yet clear on the second part of my question (how to find the number of unique occurrences).

Is there a formula or VBA code that could do this?

Using wildcards:

```
=COUNTIF(A1:A6,"="&"*"&C1&"*")
```

### Answer：

For without VBA but with some versatility, I suggest with Text in ColumnA (labelled), ColumnB labelled `Flag`

and `EuropeSpain`

in C1:

```
=FIND(C$1,A2)
```

in B2 copied down.

Then pivot A:B with `Flag`

for FILTERS (and `1`

selected), Text for ROWS and Count of Text for Sigma VALUES.

Apply Distinct Values if required (and available!), alternatively a formula of the kind:

```
=MATCH("Grand Total",E:E)-4
```

would count uniques.

Tags: excelexcel, string