Counting by answer per column

whhkwhhk

New Member
Joined
Feb 23, 2016
Messages
8
Hi everyone

Here is my problem. I have an excel table with different columns filled with the same answers : yes ; no ; n/a ; -
Here is a visual idea of what this table looks like :
A
B
C
yes
yes
no
no
n/a
no
-
-
yes
n/a
yes
no

<tbody>
</tbody>

And so on.

Now, I would like to count the number of yes ; no ; n/a ; - per column. (here for instance, for column A, it is : Yes : 1 ; No : 1 ; - : 1 ; N/A : 1)
First, I thought to use a pivot table. My problem is, I know how to do it column by column, but that way it will take ages.
So, I would like to know if there is a way to use a pivot table to do all the table at once, or if there is a better way than using a pivot table to do what I want to obtain.

Thanks,
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
you have tried using the function '=COUNTIF (A:A; "=yes") ' and then drag ?.
=COUNTIF (A:A; "=yes")
=COUNTIF (A:A; "=no")
=COUNTIF (A:A; "=n/a")
=COUNTIF (A:A; "=-")

For such a simple table it is a bit wasted the pivot table.
 
Upvote 0
Dear makexcel,

Thanks for the quick answer.

Actually, I didn't want to use Countif, I can't remember why...
Anyway, that definitively seems to be the best way to obtain the results I'm looking for.

And let say that I want to complicate a bit and count the answers yes, only when the answers in the other columns are different from yes. In that way it would give me column A, yes : 0 since for this column, the only time there is a yes answer (raw 1) there is also a yes in column B. I hope it's clear.

Do you know a way to do it ?

Thanks,
 
Upvote 0
you should set up a support column " D ", which counts the " yes " value per line and then use a conditional sum , or I can recommend a VBA function . Unfortunately now I can not help you with PIVOT tables ...


Code:
Public Function xCountYes(xRange As Range, xCol)
 'xRange is range to be analyzed
 'xCol is column that contains the value yes
 Dim x1 As Long
 For x1 = 1 To xRange.Rows.Count
  If Application.CountIf(xRange.Rows(x1), "yes") > 1 And xRange(x1, xCol) = "yes" Then
   xCountYes = xCountYes + 1
  End If
 Next x1
End Function
 
Upvote 0

Forum statistics

Threads
1,217,383
Messages
6,136,272
Members
450,001
Latest member
KWeekley08

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