Count Values in Cells

philb99

Active Member
Joined
Feb 3, 2014
Messages
389
Office Version
  1. 2010
Platform
  1. Windows
I have a list of countries recorded in Cells from A2 to A1000, some cells have 4 or more countries recorded, and I want to Count certain countries

I have been using this Formula where I have the country that I am looking for entered into Cell C1

=COUNTIF($A$2:$A$100,"*"&C$1&"*")

What it doesn't do is separate those countries with some of the same name like Sudan and South Sudan also North Korea and South Korea

Therefore can any on help with the formula
 
Good enough Mr Aladin has bailed me/us out :)

In any case, whats wrong with the formula?, could you post what your expected results are and maybe what the sample data looks like
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Thanks Aladin - reading your caveat I do not have a space after the comma and therefore this is the reason it does not work - any idea how we work it
 
Upvote 0
Thanks Momentman - the adding of Sudan = 5 in your table, this has added both Sudan and South Sudan, I require those only for Sudan which would = 4

Between my countries I only have a comma - no spaces For example Iran,Holland,Spain,Sudan.

All of my countries are recorded in A1 to say A1000 - each Cell could have 4 or more countries recorded
 
Upvote 0
Thanks Aladin - that's done the trick

Really appreciate you help
 
Upvote 0
Hey Aladin. What does the "#" symbol does?

Used in:

=SUMPRODUCT(ISNUMBER(SEARCH("#"&C$1&"#","#"&SUBSTITUTE($A$2:$A$100,", ","#")&"#"))+0)

in order to count:

C1 = Sudan

in data like:

Australia, Cuba, Holland, Sudan, Iran
Spain, Cuba, South Sudan, Canada, Germany

<TBODY>
</TBODY>

The issue is to distinguish between Sudan and South Sudan.

Note that the items are separated with a comma followed by a space (The original poster does not have space.) The formula establishes "#" as separator instead of ", ", using SUBSTITUTE. So, there isn't anything special to the "#" char. A "|" for example would be equally convenient. Try using the Evaluate Formula tool how the substitution is done.
 
Upvote 0
Thank you so much. You are probably the Grand Daddy of formula making. I'm always learning from you. :)
 
Upvote 0
Aladin - one further question if I may

We were able to Count specific countries but is there a formula I could use to establish what the top 5 countries would be from all of those recorded in Column A2 to A15000
 
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,822
Members
449,469
Latest member
Kingwi11y

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