91

I have a column like this:

What devices will you be using?

iPad
Kindle & iPad
No Tablet
iPad
iPad & Windows

How do I count the amount of people that said iPad?

This formula does work for exact matches but not if it contains an additional value:

=(COUNTIF(A2:A51,"=iPad")/COUNTA(A2:A51))*1

Any Suggestions?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Cody
  • 919
  • 1
  • 6
  • 3
  • You can use `FIND("iPad",CELL)` to check if a text is inside another text. – eLRuLL Jun 17 '13 at 16:52
  • If you have answer, please check it. – Cray Kao Aug 31 '16 at 03:27
  • @eLRuLL that appears to be for only single cells. and the below only seems to be for Google Spreadsheets only :/ EDIT: other software just handles regular expressions differently (i.e. properly)! : – Wilf Dec 19 '17 at 20:51

7 Answers7

127

It will likely have been solved by now, but I ran accross this and figured to give my input

=COUNTIF(a2:a51;"*iPad*")

The important thing is that separating parameters in google docs is using a ; and not a ,

Perry
  • 2,250
  • 2
  • 19
  • 24
86

In case someone is still looking for the answer, this worked for me:

=COUNTIF(A2:A51, "*" & B1 & "*")

B1 containing the iPad string.

David
  • 139
  • 1
  • 1
  • 12
user2983604
  • 861
  • 6
  • 2
  • 9
    this helped me because it demonstrates how to use the wildcards combined with a cell reference, rather than a hard-coded string – mike Aug 26 '15 at 00:18
  • 5
    Agree with mike, usage of the wildcards instead of cell reference or hardcode make this very useful – john Mar 21 '16 at 04:22
  • Note that this will ONLY count the number of cells that contain "iPad" and something else, so e.g. "iPad, iPhone, Samsung A32" but NOT the ones which contain "iPad" exactly. So you might need =COUNTIF(A2:A51, "*" & B1 & "*") + COUNTIF(A2:A51, B1) in the end. – ezmegy Nov 30 '22 at 13:12
13

You should use

=COUNTIF(A2:A51, "*iPad*")/COUNTA(A2:A51)

Additionally, if you wanted to count more than one element, like iPads OR Kindles, you would use

=SUM(COUNTIF(A2:A51, {"*iPad*", "*kindle*"}))/COUNTA(A2:A51)

in the numerator.

YPCrumble
  • 26,610
  • 23
  • 107
  • 172
5

Try using wildcards directly in the COUNTIF function :

=(COUNTIF(A2:A51,"=*iPad*")/COUNTA(A2:A51))*1
Simon
  • 1,605
  • 13
  • 22
4

Wildcards worked for me when the string I was searching for could be entered manually. However, I wanted to store this string in another cell and refer to it. I couldn't figure out how to do this with wildcards so I ended up doing the following:

A1 is the cell containing my search string. B and C are the columns within which I want to count the number of instances of A1, including within strings:

=COUNTIF(ARRAYFORMULA(ISNUMBER(SEARCH(A1, B:C))), TRUE)
Rupert Madden-Abbott
  • 12,899
  • 14
  • 59
  • 74
0

I had similar problem however the various count solutions still wouldn't work even with wildcards of "*"& etc..... My problem was caused by &nbsb (hidden spaces) which is hidden in the background when copying eg data from a webpage. This prevents the find from working properly. Use:

 =TRIM(SUBSTITUTE(A2, CHAR(160), " ")) 

or

 =TRIM(SUBSTITUTE(A2,CHAR(160),CHAR(32))) 

or similar to get rid of them.

ouflak
  • 2,458
  • 10
  • 44
  • 49
-7

Try just =COUNTIF(A2:A51,"iPad")

jherax
  • 5,238
  • 5
  • 38
  • 50
Kevin
  • 173
  • 1
  • 5
  • 1
    This question has already been answered. Your suggestion produces the wrong answer (only summing 'iPad' entries and excludes entries containing the 'iPad' string). – Dan Mergens Mar 22 '18 at 06:06