Assuming that your data is in columns A to C and down to row 300 (change ranges to suit your data)
Create a helper column D and enter this formula in D2 and fill down. This formula will enter a 2 if more than 1 word and 1 if a single word.
Formula:
=IFERROR(IF(FIND(" ",A2)>1,2),1)
Create another column for a unique listing of the states. I used column F and entered this formula and filled down:
Formula:
=IFERROR(INDEX($C$2:$C$300,MATCH(1,INDEX((COUNTIF($F$1:F1,$C$2:$C$300)=0)*($C$2:$C$300<>""),0),0)),"")
...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
I then used this formula in column F starting in F2 and filled down. This sums all the values for each single word cities for each state:
Formula:
=IF(F2="","",SUMIFS($B$2:$B$300,$C$2:$C$300,F2,$D$2:$D$2:$D$300,1))
Bookmarks